Remove goog.global (#5178)

* Remove goog.global

* Correct externs location

* Use Function('return this')

* Remove global externs
This commit is contained in:
Nicholas Latham
2016-04-08 09:36:48 +12:00
committed by Andreas Hocevar
parent 6efd3dab0b
commit cd6494149b
15 changed files with 54 additions and 51 deletions

View File

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