/usr/share/javascript/yui3/datasource-get/datasource-get.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('datasource-get', function(Y) {
/**
* Provides a DataSource implementation which can be used to retrieve data via the Get Utility.
*
* @module datasource
* @submodule datasource-get
*/
/**
* Get Utility subclass for the DataSource Utility.
* @class DataSource.Get
* @extends DataSource.Local
* @constructor
*/
var DSGet = function() {
DSGet.superclass.constructor.apply(this, arguments);
};
Y.DataSource.Get = Y.extend(DSGet, Y.DataSource.Local, {
/**
* Passes query string to Get Utility. Fires <code>response</code> event when
* response is received asynchronously.
*
* @method _defRequestFn
* @param e {Event.Facade} Event Facade with the following properties:
* <dl>
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
* <dt>request (Object)</dt> <dd>The request.</dd>
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
* <dl>
* <dt>success (Function)</dt> <dd>Success handler.</dd>
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
* </dl>
* </dd>
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
* </dl>
* @protected
*/
_defRequestFn: function(e) {
var uri = this.get("source"),
get = this.get("get"),
guid = Y.guid().replace(/\-/g, '_'),
generateRequest = this.get( "generateRequestCallback" ),
payload = e.details[0],
self = this;
/**
* Stores the most recent request id for validation against stale
* response handling.
*
* @property _last
* @type {String}
* @protected
*/
this._last = guid;
// Dynamically add handler function with a closure to the callback stack
// for access to guid
YUI.Env.DataSource.callbacks[guid] = function(response) {
delete YUI.Env.DataSource.callbacks[guid];
delete Y.DataSource.Local.transactions[e.tId];
var process = self.get('asyncMode') !== "ignoreStaleResponses" ||
self._last === guid;
if (process) {
payload.data = response;
self.fire("data", payload);
} else {
}
};
// Add the callback param to the request url
uri += e.request + generateRequest.call( this, guid );
Y.DataSource.Local.transactions[e.tId] = get.script(uri, {
autopurge: true,
// Works in Firefox only....
onFailure: function (o) {
delete YUI.Env.DataSource.callbacks[guid];
delete Y.DataSource.Local.transactions[e.tId];
payload.error = new Error(o.msg || "Script node data failure");
self.fire("data", payload);
},
onTimeout: function(o) {
delete YUI.Env.DataSource.callbacks[guid];
delete Y.DataSource.Local.transactions[e.tId];
payload.error = new Error(o.msg || "Script node data timeout");
self.fire("data", payload);
}
});
return e.tId;
},
/**
* Default method for adding callback param to url. See
* generateRequestCallback attribute.
*
* @method _generateRequest
* @param guid {String} unique identifier for callback function wrapper
* @protected
*/
_generateRequest: function (guid) {
return "&" + this.get("scriptCallbackParam") +
"=YUI.Env.DataSource.callbacks." + guid;
}
}, {
/**
* Class name.
*
* @property NAME
* @type String
* @static
* @final
* @value "dataSourceGet"
*/
NAME: "dataSourceGet",
////////////////////////////////////////////////////////////////////////////
//
// DataSource.Get Attributes
//
////////////////////////////////////////////////////////////////////////////
ATTRS: {
/**
* Pointer to Get Utility.
*
* @attribute get
* @type Y.Get
* @default Y.Get
*/
get: {
value: Y.Get,
cloneDefaultValue: false
},
/**
* Defines request/response management in the following manner:
* <dl>
* <!--<dt>queueRequests</dt>
* <dd>If a request is already in progress, wait until response is
* returned before sending the next request.</dd>
* <dt>cancelStaleRequests</dt>
* <dd>If a request is already in progress, cancel it before
* sending the next request.</dd>-->
* <dt>ignoreStaleResponses</dt>
* <dd>Send all requests, but handle only the response for the most
* recently sent request.</dd>
* <dt>allowAll</dt>
* <dd>Send all requests and handle all responses.</dd>
* </dl>
*
* @attribute asyncMode
* @type String
* @default "allowAll"
*/
asyncMode: {
value: "allowAll"
},
/**
* Callback string parameter name sent to the remote script. By default,
* requests are sent to
* <URI>?<scriptCallbackParam>=callbackFunction
*
* @attribute scriptCallbackParam
* @type String
* @default "callback"
*/
scriptCallbackParam : {
value: "callback"
},
/**
* Accepts the DataSource instance and a callback ID, and returns a callback
* param/value string that gets appended to the script URI. Implementers
* can customize this string to match their server's query syntax.
*
* @attribute generateRequestCallback
* @type Function
*/
generateRequestCallback : {
value: function () {
return this._generateRequest.apply(this, arguments);
}
}
}
});
YUI.namespace("Env.DataSource.callbacks");
}, '3.5.1' ,{requires:['datasource-local', 'get']});
|