diff --git a/code/chat.js b/code/chat.js index 70c995d5..a95b56ad 100644 --- a/code/chat.js +++ b/code/chat.js @@ -200,6 +200,8 @@ window.chat.handlePublic = function(data, textStatus, jqXHR) { chat.writeDataToHash(data, chat._publicData, true); var oldMsgsWereAdded = old !== chat.getOldestTimestamp(false); + runHooks('publicChatDataAvailable', {raw: data, processed: chat._publicData}); + switch(chat.getActive()) { case 'public': window.chat.renderPublic(oldMsgsWereAdded); break; case 'compact': window.chat.renderCompact(oldMsgsWereAdded); break; diff --git a/code/hooks.js b/code/hooks.js index d980c626..a1d8c98e 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -24,9 +24,15 @@ // the Leaflet CircleMarker for the portal in "portal" var. // portalDetailsUpdated: fired after the details in the sidebar have // been (re-)rendered +// publicChatDataAvailable: this hook runs after data for any of the +// public chats has been received and processed, but not +// 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. window._hooks = {} -window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated']; +window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated', + 'publicChatDataAvailable']; window.runHooks = function(event, data) { if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);