diff --git a/code/hooks.js b/code/hooks.js index 8bef1098..92840b7c 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -43,16 +43,13 @@ // 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', - 'checkRenderLimit']; + 'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender']; 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 6638955f..48704d0c 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -128,9 +128,7 @@ window.renderLimitReached = function() { if(Object.keys(portals).length >= MAX_DRAWN_PORTALS) return true; if(Object.keys(links).length >= MAX_DRAWN_LINKS) return true; if(Object.keys(fields).length >= MAX_DRAWN_FIELDS) return true; - var param = { 'reached': falseĀ }; - window.runHooks('checkRenderLimit', param); - return param.reached; + return false; } window.getMinPortalLevel = function() { diff --git a/plugins/max-links.user.js b/plugins/max-links.user.js index 5a7d2476..b1cd801f 100644 --- a/plugins/max-links.user.js +++ b/plugins/max-links.user.js @@ -20,10 +20,9 @@ function wrapper() { // use own namespace for plugin window.plugin.maxLinks = function() {}; - - window.plugin.maxLinks.MAX_DRAWN_LINKS = 400; + var MAX_LINK_COLOR = '#FF0000'; - + var Triangle = function (a, b, c) { this.a = a; this.b = b; @@ -204,8 +203,7 @@ function wrapper() { window.plugin.maxLinks.layer = null; - var updating = false; - var renderLimitReached = false; + var updating = false; window.plugin.maxLinks.updateLayer = function() { if (updating || window.plugin.maxLinks.layer === null || !window.map.hasLayer(window.plugin.maxLinks.layer)) return; @@ -232,28 +230,14 @@ function wrapper() { }); var triangles = window.plugin.maxLinks.triangulate(locations); - var drawnLinks = 0; - renderLimitReached = false; $.each(triangles, function(idx, triangle) { - if (drawnLinks <= window.plugin.maxLinks.MAX_DRAWN_LINKS) { - triangle.draw(window.plugin.maxLinks.layer, minX, minY); - drawnLinks += 3; - } else { - renderLimitReached = true; - } + triangle.draw(window.plugin.maxLinks.layer, minX, minY) }); updating = false; - window.renderUpdateStatus(); } var setup = function() { window.plugin.maxLinks.layer = L.layerGroup([]); - - window.addHook('checkRenderLimit', function(e) { - if (window.map.hasLayer(window.plugin.maxLinks.layer) && renderLimitReached) - e.reached = true; - }); - window.map.on('layeradd', function(e) { if (e.layer === window.plugin.maxLinks.layer) window.plugin.maxLinks.updateLayer();