From b00bb177481624570e52381a799d00cfd7d5ab70 Mon Sep 17 00:00:00 2001 From: Ssergni Smith Date: Thu, 15 Oct 2015 15:06:14 -0700 Subject: [PATCH] Add hook for artifact details being updated --- code/artifact.js | 2 ++ code/hooks.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/code/artifact.js b/code/artifact.js index 8d61552b..28b61b3a 100644 --- a/code/artifact.js +++ b/code/artifact.js @@ -70,9 +70,11 @@ window.artifact.processData = function(data) { return; } + var oldArtifacts = artifact.entities; artifact.clearData(); artifact.processResult(data.result); + runHooks('artifactsUpdated', {old: oldArtifacts, 'new': artifact.entities}); // redraw the artifact layer artifact.updateLayer(); diff --git a/code/hooks.js b/code/hooks.js index 26c4bb9d..9629647e 100644 --- a/code/hooks.js +++ b/code/hooks.js @@ -52,10 +52,12 @@ // this only selects the current chat pane; on mobile, it // also switches between map, info and other panes defined // by plugins +// artifactsUpdated: called when the set of artifacts (including targets) +// has changed. Parameters names are old, new. window._hooks = {} window.VALID_HOOKS = [ - 'portalSelected', 'portalDetailsUpdated', + 'portalSelected', 'portalDetailsUpdated', 'artifactsUpdated', 'mapDataRefreshStart', 'mapDataEntityInject', 'mapDataRefreshEnd', 'portalAdded', 'linkAdded', 'fieldAdded', 'publicChatDataAvailable', 'factionChatDataAvailable',