PERGOLA LOGO

Requests - Load - Save

These functions use XMLHttpRequest to: load text or data; load SVG documents; save json files (see pergola.fileDialog).

pergola.getFiles(object)

Invoke this function using the call() method to initialize the pergola.fileDialog. object specifies these properties:

The function invokes the pergola.lazyLoad.fileDialog() to build the pergola.fileDialog if it doesn't exist, and changes its title and the OK button's text. Upon successful request the array representing the retrieved files list is assigned to this[files], which (files) you would typically define as an empty array initially.

Note: if getDir is specified it overrides the default pergola.getDir, and represents the file name of alternative script on server to retrieve directory listings.

Downloading SVG documents

pergola.loadSVG(object)

Loads an SVG document or fragment and appends it to the specified container.

object defines these properties:

Issues a request using the GET method for the specified url and appends the document to the specified target if target is a container element. If target is a pergola.Window object the document will be appended to the specified container (optional), or to the default container (window.doc.transformable).

If progress is specified the referenced progress bar will be activated. If merge is specified and true the new document will be merged with existing content, otherwise it will replace the content of the destination container (whether a layer or window.doc.transformable). If resetScale is specified the window's zoom value will be reset to 1:1. Other than for a window context, container, merge, and resetScale do not apply.

pergola.saveJSON(savePath, filename, jsonObject[, url])

Saves jsonObject object as filename (string without the .json extension) to the specified savePath (string) folder. Do not stringify jsonObject.

If url string is specified, it designates the url of the server script to override the default pergola.writeFile ("writeFile.php").

pergola.saveSVG(savePath, filename, data[, url])

Saves SVG data string representing a document/fragment, as filename (string without the .svg extension) to the specified savePath (string) folder.

If url string is specified, it designates the url of the server script to override the default pergola.writeFile ("writeFile.php").

pergola.xhrGET(object)

Issues a request using the GET method for the specified object.url. If object.mime is specified the mime type will be overridden (attempt). If object.callback is specified it will be invoked asynchronously when the request is done, passing the request as parameter, allowing full processing of the response in object.callback. Example:

  pergola.xhrGET({
    url : "getDir.php",
    mime : "application/x-www-form-urlencoded",
    callback : function (request)
  });

pergola.xhrPOST(object)

Issues a request using the POST method with the specified object.url. If object.mime is specified the mime type will be overridden (attempt). The request is sent with object.params [string] as parameter. If object.callback is specified it will be invoked asynchronously when the request is done, passing the request as parameter. Example:

  pergola.xhrPOST({
    url : "getDir.php",
    params : "folder=" + path [+ ...],
    mime : "application/x-www-form-urlencoded",
    callback : function (request)
  });

pergola.xmlToJson(xml)

Converts the specified xml node/fragment to a JSON object.