Merge pull request #454 from bbarao/gh-pages
New Hook: After receiving new faction messages
This commit is contained in:
commit
c5012c2d3b
@ -152,6 +152,8 @@ window.chat.handleFaction = function(data, textStatus, jqXHR) {
|
|||||||
chat.writeDataToHash(data, chat._factionData, false);
|
chat.writeDataToHash(data, chat._factionData, false);
|
||||||
var oldMsgsWereAdded = old !== chat.getOldestTimestamp(true);
|
var oldMsgsWereAdded = old !== chat.getOldestTimestamp(true);
|
||||||
|
|
||||||
|
runHooks('factionChatDataAvailable', {raw: data, processed: chat._factionData});
|
||||||
|
|
||||||
window.chat.renderFaction(oldMsgsWereAdded);
|
window.chat.renderFaction(oldMsgsWereAdded);
|
||||||
|
|
||||||
if(data.result.length >= CHAT_FACTION_ITEMS) chat.needMoreMessages();
|
if(data.result.length >= CHAT_FACTION_ITEMS) chat.needMoreMessages();
|
||||||
|
@ -30,6 +30,11 @@
|
|||||||
// yet been displayed. The data hash contains both the un-
|
// yet been displayed. The data hash contains both the un-
|
||||||
// processed raw ajax response as well as the processed
|
// processed raw ajax response as well as the processed
|
||||||
// chat data that is going to be used for display.
|
// chat data that is going to be used for display.
|
||||||
|
// factionChatDataAvailable: this hook runs after data for the faction
|
||||||
|
// chat has been received and processed, but not yet been
|
||||||
|
// displayed. The data hash contains both the unprocessed
|
||||||
|
// 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
|
// portalDataLoaded: callback is passed the argument of
|
||||||
// {portals : [portal, portal, ...]} where "portal" is the
|
// {portals : [portal, portal, ...]} where "portal" is the
|
||||||
// data element and not the leaflet object. "portal" is an
|
// data element and not the leaflet object. "portal" is an
|
||||||
@ -46,15 +51,15 @@
|
|||||||
// checkRenderLimit: callback is passed the argument of
|
// checkRenderLimit: callback is passed the argument of
|
||||||
// {reached : false} to indicate that the renderlimit is reached
|
// {reached : false} to indicate that the renderlimit is reached
|
||||||
// set reached to true.
|
// set reached to true.
|
||||||
// requestFinished: called after each request finished. Argument is
|
// requestFinished: called after each request finished. Argument is
|
||||||
// {success: boolean} indicated the request success or fail.
|
// {success: boolean} indicated the request success or fail.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window._hooks = {}
|
window._hooks = {}
|
||||||
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
|
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
|
||||||
'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender',
|
'publicChatDataAvailable', 'factionChatDataAvailable', 'portalDataLoaded',
|
||||||
'checkRenderLimit', 'requestFinished'];
|
'beforePortalReRender', 'checkRenderLimit', 'requestFinished'];
|
||||||
|
|
||||||
window.runHooks = function(event, data) {
|
window.runHooks = function(event, data) {
|
||||||
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user