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
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
* Ext JS Library 3.4.0
* Copyright(c) 2006-2011 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
Ext.ns('Ext.ux');
Ext.ux.JSONP = (function(){
var _queue = [],
_current = null,
_nextRequest = function() {
_current = null;
if(_queue.length) {
_current = _queue.shift();
_current.script.src = _current.url + '?' + _current.params;
document.getElementsByTagName('head')[0].appendChild(_current.script);
}
};
return {
request: function(url, o) {
if(!url) {
return;
}
var me = this;
o.params = o.params || {};
if(o.callbackKey) {
o.params[o.callbackKey] = 'Ext.ux.JSONP.callback';
}
var params = Ext.urlEncode(o.params);
var script = document.createElement('script');
script.type = 'text/javascript';
if(o.isRawJSON) {
if(Ext.isIE) {
Ext.fly(script).on('readystatechange', function() {
if(script.readyState == 'complete') {
var data = script.innerHTML;
if(data.length) {
me.callback(Ext.decode(data));
}
}
});
}
else {
Ext.fly(script).on('load', function() {
var data = script.innerHTML;
if(data.length) {
me.callback(Ext.decode(data));
}
});
}
}
_queue.push({
url: url,
script: script,
callback: o.callback || function(){},
scope: o.scope || window,
params: params || null
});
if(!_current) {
_nextRequest();
}
},
callback: function(json) {
_current.callback.apply(_current.scope, [json]);
Ext.fly(_current.script).removeAllListeners();
document.getElementsByTagName('head')[0].removeChild(_current.script);
_nextRequest();
}
}
})();</pre>
</body>
</html>
|