67
/** Converts a list of directories into a path name, with a slash at the end.
68
* \param pathlist List of strings.
71
function pathlist_to_path(pathlist)
74
for (var i=0; i<pathlist.length; i++)
76
ret += pathlist[i] + "/";
81
67
/** Given a URL, returns an object containing a number of attributes
82
68
* describing the components of the URL, similar to CGI request variables.
83
69
* The object has the following attributes:
314
/** Converts a list of directories into a path name, with a slash at the end.
315
* \param pathlist List of strings.
318
function pathlist_to_path(pathlist)
320
ret = path_join.apply(null, pathlist);
321
if (ret[ret.length-1] != '/')
328
326
/** Given a path relative to the IVLE root, gives a path relative to
333
331
return path_join(root_dir, path);
334
/** Makes an XMLHttpRequest call to the server. Waits (synchronously) for a
335
* response, and returns an XMLHttpRequest object containing the completed
338
* \param app IVLE app to call (such as "fileservice").
339
* \param path URL path to make the request to, within the application.
340
* \param args Argument object, as described in parse_url and friends.
341
* \param method String; "GET" or "POST"
342
* \return An XMLHttpRequest object containing the completed response.
344
function ajax_call(app, path, args, method)
346
path = make_path(path_join(app, path));
348
var xhr = new XMLHttpRequest();
351
/* GET sends the args in the URL */
352
url = build_url({"path": path, "args": args});
353
/* open's 3rd argument = false -> SYNCHRONOUS (wait for response)
354
* (No need for a callback function) */
355
xhr.open(method, url, false);
360
/* POST sends the args in application/x-www-form-urlencoded */
361
url = encodeURI(path);
362
xhr.open(method, url, false);
363
xhr.setRequestHeader("Content-Type",
364
"application/x-www-form-urlencoded");
365
var message = build_url({"args": args}).substr(1); /* Remove "?" */