new hook to let plugins indicate a renderlimit

This commit is contained in:
Florian Sundermann 2013-02-25 08:44:43 +01:00
parent 67d4fbbe03
commit 459c4b422b
2 changed files with 8 additions and 2 deletions

View File

@ -43,13 +43,17 @@
// redrawn. It is called early on in the
// code/map_data.js#renderPortal as long as there was an
// old portal for the guid.
// checkRenderLimit: callback is passed the argument of
// {reached : false} to indicate that the renderlimit is reached
// set reached to true.
window._hooks = {}
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender'];
'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender',
'checkRenderLimit'];
window.runHooks = function(event, data) {
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);

View File

@ -135,7 +135,9 @@ window.renderLimitReached = function(ratio) {
if(Object.keys(portals).length*ratio >= MAX_DRAWN_PORTALS) return true;
if(Object.keys(links).length*ratio >= MAX_DRAWN_LINKS) return true;
if(Object.keys(fields).length*ratio >= MAX_DRAWN_FIELDS) return true;
return false;
var param = { 'reached': false };
window.runHooks('checkRenderLimit', param);
return param.reached;
}
window.getMinPortalLevel = function() {