1 |
efrain |
1 |
YUI.add('yql-winjs', function (Y, NAME) {
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* WinJS plugin for YQL to use native XHR to make requests instead of JSONP.
|
|
|
5 |
* Not required by the user, it's conditionally loaded and should "just work".
|
|
|
6 |
* @module yql
|
|
|
7 |
* @submodule yql-winjs
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
//Over writes Y.YQLRequest._send to use IO instead of JSONP
|
|
|
11 |
Y.YQLRequest.prototype._send = function (url, o) {
|
|
|
12 |
var req = new XMLHttpRequest(),
|
|
|
13 |
timer;
|
|
|
14 |
|
|
|
15 |
req.open('GET', url, true);
|
|
|
16 |
req.onreadystatechange = function () {
|
|
|
17 |
if (req.readyState === 4) { //Complete
|
|
|
18 |
//No status code check here, since the YQL service will return JSON
|
|
|
19 |
clearTimeout(timer);
|
|
|
20 |
//No need to "call" this, YQL handles the context
|
|
|
21 |
o.on.success(JSON.parse(req.responseText));
|
|
|
22 |
}
|
|
|
23 |
};
|
|
|
24 |
req.send();
|
|
|
25 |
|
|
|
26 |
//Simple timer to catch no connections
|
|
|
27 |
timer = setTimeout(function() {
|
|
|
28 |
req.abort();
|
|
|
29 |
o.on.timeout('script timeout');
|
|
|
30 |
}, o.timeout || 30000);
|
|
|
31 |
};
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
}, '3.18.1', {"requires": ["yql"]});
|