// STATUS BAR ///////////////////////////////////////
// gives user feedback about pending operations. Draws current status
// to website. Updates info in layer chooser.
window.renderUpdateStatusTimer_ = undefined;
window.renderUpdateStatus = function() {
var progress = 1;
// portal/limk level display
var zoom = map.getZoom();
zoom = getDataZoomForMapZoom(zoom);
var minLinkLength;
if (zoom <= 4) minLinkLength = 200000;
else if (zoom <= 6) minLinkLength = 60000;
else if (zoom <= 7) minLinkLength = 10000;
else if (zoom <= 8) minLinkLength = 5000;
else if (zoom <= 10) minLinkLength = 2500;
else if (zoom <= 11) minLinkLength = 800;
else if (zoom <= 12) minLinkLength = 300;
else if (zoom <= 14) minLinkLength = 0; // 0 means 'all links, but not all portals'
else minLinkLength = -1; // -1 means 'all links and portals by min level'
var minlvl = getMinPortalLevel();
var t = '';
if (minLinkLength == -1) {
if(!window.isSmartphone()) // space is valuable
t += 'portals: ';
if(minlvl === 0)
t += 'all';
else
t += 'L'+minlvl+(minlvl<8?'+':'') + '';
} else {
if(!window.isSmartphone()) // space is valuable
t += 'links: ';
if (minLinkLength > 0)
t += '>'+(minLinkLength>1000?minLinkLength/1000+'km':minLinkLength+'m')+'';
else
t += 'all links';
}
t +='';
// map status display
t += ' map: ';
if (window.mapDataRequest) {
var status = window.mapDataRequest.getStatus();
// status.short - short description of status
// status.long - longer description, for tooltip (optional)
// status.progress - fractional progress (from 0 to 1; -1 for indeterminate) of current state (optional)
if (status.long)
t += ''+status.short+'';
else
t += ''+status.short+'';
if (status.progress !== undefined) {
if(status.progress !== -1)
t += ' '+Math.floor(status.progress*100)+'%';
progress = status.progress;
}
} else {
// no mapDataRequest object - no status known
t += '...unknown...';
}
t += '';
//request status
if (window.activeRequests.length > 0)
t += ' ' + window.activeRequests.length + ' requests';
if (window.failedRequestCount > 0)
t += ' ' + window.failedRequestCount + ' failed'
//it's possible that updating the status bar excessively causes some performance issues. so rather than doing it
//immediately, delay it to the next javascript event loop, cancelling any pending update
// will also cause any browser-related rendering to occur first, before the status actually updates
if (window.renderUpdateStatusTimer_) clearTimeout(window.renderUpdateStatusTimer_);
window.renderUpdateStatusTimer_ = setTimeout ( function() {
window.renderUpdateStatusTimer_ = undefined;
$('#innerstatus').html(t);
//$('#updatestatus').click(function() { startRefreshTimeout(10); });
//. ⟳';
if(progress == 1 && window.activeRequests.length > 0) {
// we don't know the exact progress, but we have requests (e.g. chat) running, so show it as indeterminate.
progress = -1;
}
if (typeof android !== 'undefined' && android && android.setProgress)
android.setProgress(progress);
}, 0);
}