Code restructure 3
This commit is contained in:
parent
a679710198
commit
4113991201
@ -49,17 +49,25 @@ window.requestData = function() {
|
|||||||
$.each(tiles, function(ind, tls) {
|
$.each(tiles, function(ind, tls) {
|
||||||
data = { minLevelOfDetail: -1 };
|
data = { minLevelOfDetail: -1 };
|
||||||
data.boundsParamsList = tls;
|
data.boundsParamsList = tls;
|
||||||
window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, portalRenderLimit.handleFailRequest));
|
window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle failed map data request
|
||||||
|
window.handleFailedRequest = function() {
|
||||||
|
if(requests.isLastRequest('getThinnedEntitiesV2')) {
|
||||||
|
var leftOverPortals = portalRenderLimit.mergeLowLevelPortals(null);
|
||||||
|
handlePortalsRender(leftOverPortals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// works on map data response and ensures entities are drawn/updated.
|
// works on map data response and ensures entities are drawn/updated.
|
||||||
window.handleDataResponse = function(data, textStatus, jqXHR) {
|
window.handleDataResponse = function(data, textStatus, jqXHR) {
|
||||||
// remove from active ajax queries list
|
// remove from active ajax queries list
|
||||||
if(!data || !data.result) {
|
if(!data || !data.result) {
|
||||||
window.failedRequestCount++;
|
window.failedRequestCount++;
|
||||||
console.warn(data);
|
console.warn(data);
|
||||||
portalRenderLimit.handleFailRequest();
|
handleFailedRequest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,20 +82,13 @@ window.portalRenderLimit.splitOrMergeLowLevelPortals = function(originPortals) {
|
|||||||
portalRenderLimit.resetCounting();
|
portalRenderLimit.resetCounting();
|
||||||
portalRenderLimit.countingPortals(originPortals);
|
portalRenderLimit.countingPortals(originPortals);
|
||||||
|
|
||||||
var resultPortals = portalRenderLimit.isLastRequest()
|
var resultPortals = requests.isLastRequest('getThinnedEntitiesV2')
|
||||||
? portalRenderLimit.mergeLowLevelPortals(originPortals)
|
? portalRenderLimit.mergeLowLevelPortals(originPortals)
|
||||||
: portalRenderLimit.splitLowLevelPortals(originPortals);
|
: portalRenderLimit.splitLowLevelPortals(originPortals);
|
||||||
|
|
||||||
return resultPortals;
|
return resultPortals;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.portalRenderLimit.handleFailRequest = function() {
|
|
||||||
if(portalRenderLimit.isLastRequest()) {
|
|
||||||
var resultPortals = portalRenderLimit.mergeLowLevelPortals(null);
|
|
||||||
handlePortalsRender(resultPortals);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.portalRenderLimit.countingPortals = function(portals) {
|
window.portalRenderLimit.countingPortals = function(portals) {
|
||||||
$.each(portals, function(ind, portal) {
|
$.each(portals, function(ind, portal) {
|
||||||
var portalGuid = portal[0];
|
var portalGuid = portal[0];
|
||||||
@ -134,17 +127,6 @@ window.portalRenderLimit.mergeLowLevelPortals = function(appendTo) {
|
|||||||
return resultPortals;
|
return resultPortals;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.portalRenderLimit.isLastRequest = function() {
|
|
||||||
var result = true;
|
|
||||||
$.each(window.activeRequests, function(ind, req) {
|
|
||||||
if(req.action === 'getThinnedEntitiesV2') {
|
|
||||||
result = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.portalRenderLimit.getMinLevel = function() {
|
window.portalRenderLimit.getMinLevel = function() {
|
||||||
if(!portalRenderLimit.initialized) return -1;
|
if(!portalRenderLimit.initialized) return -1;
|
||||||
if(!portalRenderLimit.minLevelSet) portalRenderLimit.setMinLevel();
|
if(!portalRenderLimit.minLevelSet) portalRenderLimit.setMinLevel();
|
||||||
|
@ -111,3 +111,14 @@ window.requests._callOnRefreshFunctions = function() {
|
|||||||
window.requests.addRefreshFunction = function(f) {
|
window.requests.addRefreshFunction = function(f) {
|
||||||
window.requests._onRefreshFunctions.push(f);
|
window.requests._onRefreshFunctions.push(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.requests.isLastRequest = function(action) {
|
||||||
|
var result = true;
|
||||||
|
$.each(window.activeRequests, function(ind, req) {
|
||||||
|
if(req.action === action) {
|
||||||
|
result = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user