Add error handling for missing component javascript files

This commit is contained in:
Mike Primm 2011-09-07 21:44:11 -05:00
parent 402d7f9542
commit a77f002054

View File

@ -307,7 +307,9 @@ DynMap.prototype = {
configset[configuration.type].push(configuration); configset[configuration.type].push(configuration);
}); });
var tobeloaded = {};
$.each(configset, function(type, configlist) { $.each(configset, function(type, configlist) {
tobeloaded[type] = true;
loadjs('js/' + type + '.js', function() { loadjs('js/' + type + '.js', function() {
var componentconstructor = componentconstructors[type]; var componentconstructor = componentconstructors[type];
if (componentconstructor) { if (componentconstructor) {
@ -317,6 +319,7 @@ DynMap.prototype = {
} else { } else {
// Could not load component. We'll ignore this for the moment. // Could not load component. We'll ignore this for the moment.
} }
delete tobeloaded[type];
componentstoload--; componentstoload--;
if (componentstoload == 0) { if (componentstoload == 0) {
// Actually start updating once all components are loaded. // Actually start updating once all components are loaded.
@ -324,6 +327,17 @@ DynMap.prototype = {
} }
}); });
}); });
setTimeout(function() {
$.each(configset, function(type, configlist) {
if(tobeloaded[type]) {
me.alertbox
.text('Error loading js/' + type + '.js')
.show();
}
});
if(componentstoload > 0)
setTimeout(function() { me.update(); }, me.options.updaterate);
}, 15000);
}, },
getProjection: function() { return this.maptype.getProjection(); }, getProjection: function() { return this.maptype.getProjection(); },
selectMapAndPan: function(map, location, completed) { selectMapAndPan: function(map, location, completed) {