1
0
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:
hallgren
2012-11-23 18:51:44 +00:00
parent 53858fbc81
commit e0e8f89484
2 changed files with 21 additions and 14 deletions

View File

@@ -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

View File

@@ -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) {