From 459c4b422bcd26bba32f4e17083e1c89b19764a4 Mon Sep 17 00:00:00 2001 From: Florian Sundermann Date: Mon, 25 Feb 2013 08:44:43 +0100 Subject: [PATCH] new hook to let plugins indicate a renderlimit --- code/hooks.js | 6 +++++- code/utils_misc.js | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code/hooks.js b/code/hooks.js index 92840b7c..fbf5c602 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -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); diff --git a/code/utils_misc.js b/code/utils_misc.js index e208fcc0..8600a0ed 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -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() {