summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-11-23 18:51:44 +0000
committerhallgren <hallgren@chalmers.se>2012-11-23 18:51:44 +0000
commite0e8f89484efaec39e77e5c645697d311baaa0e4 (patch)
treecdf09458cdbd6717854cfb4db81a43412221f264 /src
parent53858fbc81fb2e1844bd43aa579a8b521f4606b5 (diff)
gfse: use POST requests when parsing grammar modules after editing as text
instead of GET, to avoid the Apache httpd URI length limitation. This means that gfse can no longer use JSONP when parsing grammars, so it has to be located on the same host as the cloud service. Also clean away trailing white space in support.js.
Diffstat (limited to 'src')
-rw-r--r--src/www/gfse/cloud2.js3
-rw-r--r--src/www/js/support.js32
2 files changed, 21 insertions, 14 deletions
diff --git a/src/www/gfse/cloud2.js b/src/www/gfse/cloud2.js
index d949a6ccc..ce5371145 100644
--- a/src/www/gfse/cloud2.js
+++ b/src/www/gfse/cloud2.js
@@ -259,7 +259,8 @@ function gfshell(cmd,cont) {
// Check the syntax of a source module
function check_module(path,source,cont) {
var enc=encodeURIComponent;
- http_get_json("/parse?"+enc(path)+"="+enc(source),cont)
+ //http_get_json("/parse?"+enc(path)+"="+enc(source),cont)
+ ajax_http_post_json("/parse",enc(path)+"="+enc(source),cont)
}
// Check the syntax of an expression
diff --git a/src/www/js/support.js b/src/www/js/support.js
index 41b736855..eefda3f8b 100644
--- a/src/www/js/support.js
+++ b/src/www/js/support.js
@@ -31,28 +31,28 @@ if(!Array.isArray) {
/* --- JSONP ---------------------------------------------------------------- */
-// Inspired by the function jsonp from
+// Inspired by the function jsonp from
// http://www.west-wind.com/Weblog/posts/107136.aspx
// See also http://niryariv.wordpress.com/2009/05/05/jsonp-quickly/
// http://en.wikipedia.org/wiki/JSONP
function jsonp(url,callback)
-{
+{
if (url.indexOf("?") > -1)
- url += "&jsonp="
+ url += "&jsonp="
else
- url += "?jsonp="
+ url += "?jsonp="
url += callback;
- //url += "&" + new Date().getTime().toString(); // prevent caching
-
- var script = empty("script");
+ //url += "&" + new Date().getTime().toString(); // prevent caching
+
+ var script = empty("script");
script.setAttribute("src",url);
- script.setAttribute("type","text/javascript");
+ script.setAttribute("type","text/javascript");
document.body.appendChild(script);
}
var json = {next:0};
-// Like jsonp, but instead of passing the name of the callback function, you
+// Like jsonp, but instead of passing the name of the callback function, you
// pass the callback function directly, making it possible to use anonymous
// functions.
function jsonpf(url,callback,errorcallback)
@@ -65,7 +65,7 @@ function jsonpf(url,callback,errorcallback)
/* --- AJAX ----------------------------------------------------------------- */
function GetXmlHttpObject(handler)
-{
+{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
@@ -116,9 +116,15 @@ function ajax_http_post(url,formdata,callback,errorcallback) {
// JSON via AJAX
function ajax_http_get_json(url,cont,errorcallback) {
- ajax_http_get(url,function(txt){cont(eval("("+txt+")"));}, errorcallback);
+ ajax_http_get(url, with_json(cont), errorcallback);
}
+function ajax_http_post_json(url,formdata,cont,errorcallback) {
+ ajax_http_post(url, formdata, with_json(cont), errorcallback);
+}
+
+function with_json(cont) { return function(txt){cont(eval("("+txt+")"));} }
+
function sameOrigin(url) {
var a=empty("a");
a.href=url; // converts to an absolute URL
@@ -169,7 +175,7 @@ function wrap(tag,contents) {
function wrap_class(tag,cls,contents) {
return node(tag,{"class":cls},
- contents ? Array.isArray(contents) ?
+ contents ? Array.isArray(contents) ?
contents : [contents] : [])
}
@@ -310,7 +316,7 @@ function map(f,xs) {
return ys;
}
-// map in continuation passing style
+// map in continuation passing style
function mapc(f,xs,cont) { mapc_from(f,xs,0,[],cont); }
function mapc_from(f,xs,i,ys,cont) {