2
* @author Patrick Schmiedel patrick.schmiedel@gmx.net
6
* @classDescription Static class. Keeps a cache of retrieved urls.
9
/*global Class, Control, document, $, $A, Ajax, Debug */
10
var AjaxRequestWrapper = Class.create();
12
AjaxRequestWrapper.cache = {};
15
* @classDescription Wraps a GET url request to contain state
16
* information like the url, and simplifies the use by setting some
18
* TODO: Create a non-cached version for retrieving data that is
21
AjaxRequestWrapper.getCached = Class.create();
23
AjaxRequestWrapper.getCached.prototype = {
25
* @constructor Creates a new instance and processes the request.
26
* @param {String} url The url to retrieve.
27
* @param {Function} callback The function that handles the retrieved data.
29
initialize: function (url, callback) {
33
this.callback = callback;
35
// Get any additional arguments for XHR. The first two items of the array are
36
// the url and callback function for the XHR. In many cases this.arguments will
38
this.args = $A(arguments).slice(2);
42
if (AjaxRequestWrapper.cache[url]) {
43
callback.apply(null, $A([AjaxRequestWrapper.cache[self.url]]).concat(self.args));
45
var onSuccess = function (transport) {
46
AjaxRequestWrapper.cache[self.url] = transport.responseText;
47
callback.apply(null, $A([AjaxRequestWrapper.cache[self.url]]).concat(self.args));
50
var onFailure = function (transport) {
51
Debug.ajaxFailure(transport, self.url);
54
var trash = new Ajax.Request(