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