forked from GitHub/gf-core
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.
This commit is contained in:
@@ -259,7 +259,8 @@ function gfshell(cmd,cont) {
|
|||||||
// Check the syntax of a source module
|
// Check the syntax of a source module
|
||||||
function check_module(path,source,cont) {
|
function check_module(path,source,cont) {
|
||||||
var enc=encodeURIComponent;
|
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
|
// Check the syntax of an expression
|
||||||
|
|||||||
@@ -31,28 +31,28 @@ if(!Array.isArray) {
|
|||||||
|
|
||||||
/* --- JSONP ---------------------------------------------------------------- */
|
/* --- JSONP ---------------------------------------------------------------- */
|
||||||
|
|
||||||
// Inspired by the function jsonp from
|
// Inspired by the function jsonp from
|
||||||
// http://www.west-wind.com/Weblog/posts/107136.aspx
|
// http://www.west-wind.com/Weblog/posts/107136.aspx
|
||||||
// See also http://niryariv.wordpress.com/2009/05/05/jsonp-quickly/
|
// See also http://niryariv.wordpress.com/2009/05/05/jsonp-quickly/
|
||||||
// http://en.wikipedia.org/wiki/JSONP
|
// http://en.wikipedia.org/wiki/JSONP
|
||||||
function jsonp(url,callback)
|
function jsonp(url,callback)
|
||||||
{
|
{
|
||||||
if (url.indexOf("?") > -1)
|
if (url.indexOf("?") > -1)
|
||||||
url += "&jsonp="
|
url += "&jsonp="
|
||||||
else
|
else
|
||||||
url += "?jsonp="
|
url += "?jsonp="
|
||||||
url += callback;
|
url += callback;
|
||||||
//url += "&" + new Date().getTime().toString(); // prevent caching
|
//url += "&" + new Date().getTime().toString(); // prevent caching
|
||||||
|
|
||||||
var script = empty("script");
|
var script = empty("script");
|
||||||
script.setAttribute("src",url);
|
script.setAttribute("src",url);
|
||||||
script.setAttribute("type","text/javascript");
|
script.setAttribute("type","text/javascript");
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = {next:0};
|
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
|
// pass the callback function directly, making it possible to use anonymous
|
||||||
// functions.
|
// functions.
|
||||||
function jsonpf(url,callback,errorcallback)
|
function jsonpf(url,callback,errorcallback)
|
||||||
@@ -65,7 +65,7 @@ function jsonpf(url,callback,errorcallback)
|
|||||||
/* --- AJAX ----------------------------------------------------------------- */
|
/* --- AJAX ----------------------------------------------------------------- */
|
||||||
|
|
||||||
function GetXmlHttpObject(handler)
|
function GetXmlHttpObject(handler)
|
||||||
{
|
{
|
||||||
var objXMLHttp=null
|
var objXMLHttp=null
|
||||||
if (window.XMLHttpRequest)
|
if (window.XMLHttpRequest)
|
||||||
{
|
{
|
||||||
@@ -116,9 +116,15 @@ function ajax_http_post(url,formdata,callback,errorcallback) {
|
|||||||
|
|
||||||
// JSON via AJAX
|
// JSON via AJAX
|
||||||
function ajax_http_get_json(url,cont,errorcallback) {
|
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) {
|
function sameOrigin(url) {
|
||||||
var a=empty("a");
|
var a=empty("a");
|
||||||
a.href=url; // converts to an absolute URL
|
a.href=url; // converts to an absolute URL
|
||||||
@@ -169,7 +175,7 @@ function wrap(tag,contents) {
|
|||||||
|
|
||||||
function wrap_class(tag,cls,contents) {
|
function wrap_class(tag,cls,contents) {
|
||||||
return node(tag,{"class":cls},
|
return node(tag,{"class":cls},
|
||||||
contents ? Array.isArray(contents) ?
|
contents ? Array.isArray(contents) ?
|
||||||
contents : [contents] : [])
|
contents : [contents] : [])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +316,7 @@ function map(f,xs) {
|
|||||||
return ys;
|
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(f,xs,cont) { mapc_from(f,xs,0,[],cont); }
|
||||||
|
|
||||||
function mapc_from(f,xs,i,ys,cont) {
|
function mapc_from(f,xs,i,ys,cont) {
|
||||||
|
|||||||
Reference in New Issue
Block a user