From 5a187be3a8ad1a0201f2f4d8e6cc327ce176c5bd Mon Sep 17 00:00:00 2001 From: fkloft Date: Wed, 23 Jul 2014 11:20:04 +0200 Subject: [PATCH] uniques: use owner information from portal details --- plugins/uniques.user.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/uniques.user.js b/plugins/uniques.user.js index 579f2792..29c5c8cb 100644 --- a/plugins/uniques.user.js +++ b/plugins/uniques.user.js @@ -38,12 +38,30 @@ window.plugin.uniques.enableSync = false; window.plugin.uniques.disabledMessage = null; window.plugin.uniques.contentHTML = null; -window.plugin.uniques.addToSidebar = function() { +window.plugin.uniques.onPortalDetailsUpdated = function() { if(typeof(Storage) === "undefined") { $('#portaldetails > .imgpreview').after(plugin.uniques.disabledMessage); return; } + var guid = window.selectedPortal, + details = portalDetail.get(guid), + nickname = window.PLAYER.nickname; + if(details) { + if(details.owner == nickname) { + plugin.uniques.updateCaptured(true); + // no further logic required + } else { + function installedByPlayer(entity) { + return entity && entity.owner == nickname; + } + + if(details.resonators.some(installedByPlayer) || details.mods.some(installedByPlayer)) { + plugin.uniques.updateVisited(true); + } + } + } + $('#portaldetails > .imgpreview').after(plugin.uniques.contentHTML); plugin.uniques.updateChecked(); } @@ -222,7 +240,7 @@ var setup = function() { window.plugin.uniques.setupCSS(); window.plugin.uniques.setupContent(); window.plugin.uniques.loadLocal(window.plugin.uniques.KEY); - window.addHook('portalDetailsUpdated', window.plugin.uniques.addToSidebar); + window.addHook('portalDetailsUpdated', window.plugin.uniques.onPortalDetailsUpdated); window.addHook('iitcLoaded', window.plugin.uniques.registerFieldForSyncing); window.addPortalHighlighter('Uniques', window.plugin.uniques.highlight); }