Remove ol.global

This commit is contained in:
Tim Schaub
2016-09-01 22:28:20 -06:00
parent 785639338b
commit 651c6959ab
20 changed files with 55 additions and 96 deletions

View File

@@ -15,24 +15,23 @@ goog.require('ol');
* callback. Default is 'callback'.
*/
ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) {
var global = ol.global;
var script = global.document.createElement('script');
var script = document.createElement('script');
var key = 'olc_' + ol.getUid(callback);
function cleanup() {
delete global[key];
delete window[key];
script.parentNode.removeChild(script);
}
script.async = true;
script.src = url + (url.indexOf('?') == -1 ? '?' : '&') +
(opt_callbackParam || 'callback') + '=' + key;
var timer = global.setTimeout(function() {
var timer = setTimeout(function() {
cleanup();
if (opt_errback) {
opt_errback();
}
}, 10000);
global[key] = function(data) {
global.clearTimeout(timer);
window[key] = function(data) {
clearTimeout(timer);
cleanup();
callback(data);
};