diff --git a/code/hooks.js b/code/hooks.js index 1aff0010..43f4cc35 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -30,11 +30,16 @@ // yet been displayed. The data hash contains both the un- // processed raw ajax response as well as the processed // chat data that is going to be used for display. - +// portalDataLoaded: callback is passed the argument of +// {portals : [portal, portal, ...]} where "portal" is the +// data element and not the leaflet object. "portal" is an +// array [GUID, time, details]. Plugin can manipulate the +// array to change order or add additional values to the +// details of a portal. window._hooks = {} window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated', - 'publicChatDataAvailable']; + 'publicChatDataAvailable', 'portalDataLoaded']; window.runHooks = function(event, data) { if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event); diff --git a/code/map_data.js b/code/map_data.js index dc370cd6..6729c0f0 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -127,6 +127,8 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // Preserve and restore "selectedPortal" between portal re-render if(portalUpdateAvailable) var oldSelectedPortal = selectedPortal; + + runHooks('portalDataLoaded', {portals : ppp}); $.each(ppp, function(ind, portal) { renderPortal(portal); }); var selectedPortalLayer = portals[oldSelectedPortal];