From b10183e1e4e72ea7920d85582c21bb79e65aae1b Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Sat, 2 Apr 2016 11:56:17 +0200 Subject: [PATCH 01/38] First commit --- IngressUniqueExporter.user.js | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 IngressUniqueExporter.user.js diff --git a/IngressUniqueExporter.user.js b/IngressUniqueExporter.user.js new file mode 100644 index 000000000..a7f6473dd --- /dev/null +++ b/IngressUniqueExporter.user.js @@ -0,0 +1,72 @@ +// ==UserScript== +// @id iitc-plugin-uniqueinfo-exporter@c-schmitz +// @name IITC plugin: Unique Info Import/Export +// @category Misc +// @version 0.0.0.2 +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @description Import/exports the unique capture/visits info to/from a JSON file. This plugin requires the IITC Unique plugin to be installed. +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// @grant none +// ==/UserScript== + +function wrapper() { + // in case IITC is not available yet, define the base plugin object + if (typeof window.plugin !== "function") { + window.plugin = function() {}; + } + // base context for plugin + window.plugin.uniqueinfo = function() {}; + var self = window.plugin.uniqueinfo; + self.gen = function gen() { + + sExportUniqueJSON='{'+"\n"; + aoPortals=window.plugin.uniques.uniques; + visited=captured=0; + $.each(aoPortals,function(PUID){ + aPortal=window.plugin.uniques.uniques[PUID]; + sExportUniqueJSON+='"'+PUID+'": {"visited":'+aPortal.visited+',"captured":'+aPortal.captured+"},\n"; + i++; + if (aPortal.visited) visited++; + if (aPortal.captured) captured++; + }); + sExportUniqueJSON=sExportUniqueJSON.slice(0, -2); + sExportUniqueJSON+="\n"+'}'+"\n" + + var dialog = window.dialog({ + title: "Ingress unique visits/cpatures JSON export", + html: 'Find all of your visited/captured portals as JSON below (visited: '+visited+' - vaptured: '+captured+'):' + + '' + }).parent(); + $(".ui-dialog-buttonpane", dialog).remove(); + // width first, then centre + dialog.css("width", 600).css({ + "top": ($(window).height() - dialog.height()) / 2, + "left": ($(window).width() - dialog.width()) / 2 + }); + $("#idmUnqiuesExport").val(sExportUniqueJSON); + return dialog; + } + // setup function called by IITC + self.setup = function init() { + // add controls to toolbox + var link = $("Unique visits/capture export"); + $("#toolbox").append(link); + // delete setup to ensure init can't be run again + delete self.setup; + } + // IITC plugin setup + if (window.iitcLoaded && typeof self.setup === "function") { + self.setup(); + } else if (window.bootPlugins) { + window.bootPlugins.push(self.setup); + } else { + window.bootPlugins = [self.setup]; + } +} +// inject plugin into page +var script = document.createElement("script"); +script.appendChild(document.createTextNode("(" + wrapper + ")();")); +(document.body || document.head || document.documentElement).appendChild(script); From 48480ae8f62bc6ebe618022c610e5ea5006e5e20 Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Sat, 2 Apr 2016 11:59:22 +0200 Subject: [PATCH 02/38] Fixed linebreaks --- IngressUniqueExporter.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IngressUniqueExporter.user.js b/IngressUniqueExporter.user.js index a7f6473dd..13f7273d4 100644 --- a/IngressUniqueExporter.user.js +++ b/IngressUniqueExporter.user.js @@ -1,4 +1,4 @@ -// ==UserScript== +// ==UserScript== // @id iitc-plugin-uniqueinfo-exporter@c-schmitz // @name IITC plugin: Unique Info Import/Export // @category Misc From 4bbc74d02806d318cbc5fb7649175e073206f522 Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Sat, 2 Apr 2016 12:06:53 +0200 Subject: [PATCH 03/38] Create README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..a9ec72e2d --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# iitc-unique-export + +This is an IITC plugin to export your unique captures/visits from IITC as a JSON format. +The Uniques plugins and a functioning syncronisation is required, of course. + +The exported data consists of the Unique Portal ID, visited and captured status, all in JSON format. From 84aaf3c43ebc9181f153c42bce460711bed092fb Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Sun, 3 Apr 2016 23:50:48 +0200 Subject: [PATCH 04/38] -Added import - will never delete, only update portals --- IngressUniqueExporter.user.js | 28 +++++++++++++++++----------- README.md | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/IngressUniqueExporter.user.js b/IngressUniqueExporter.user.js index 13f7273d4..4efde078d 100644 --- a/IngressUniqueExporter.user.js +++ b/IngressUniqueExporter.user.js @@ -1,9 +1,11 @@ -// ==UserScript== +// ==UserScript== // @id iitc-plugin-uniqueinfo-exporter@c-schmitz // @name IITC plugin: Unique Info Import/Export // @category Misc -// @version 0.0.0.2 +// @version 0.0.0.3 // @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL https://github.com/c-schmitz/iitc-unique-export/raw/master/IngressUniqueExporter.user.js +// @downloadURL https://github.com/c-schmitz/iitc-unique-export/raw/master/IngressUniqueExporter.user.js // @description Import/exports the unique capture/visits info to/from a JSON file. This plugin requires the IITC Unique plugin to be installed. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* @@ -20,6 +22,13 @@ function wrapper() { // base context for plugin window.plugin.uniqueinfo = function() {}; var self = window.plugin.uniqueinfo; + self.save = function save() { + if (!confirm("Please only confirm this if you know what you are doing!!\nAre you sure you want to save your Unique visits/captures back to IITC?")) return; + + window.plugin.uniques.uniques=$.parseJSON( $('#taUCExportImport').val() ); + window.plugin.sync.updateMap('uniques', 'uniques', Object.keys(window.plugin.uniques.uniques)); + } + self.gen = function gen() { sExportUniqueJSON='{'+"\n"; @@ -27,18 +36,15 @@ function wrapper() { visited=captured=0; $.each(aoPortals,function(PUID){ aPortal=window.plugin.uniques.uniques[PUID]; - sExportUniqueJSON+='"'+PUID+'": {"visited":'+aPortal.visited+',"captured":'+aPortal.captured+"},\n"; - i++; if (aPortal.visited) visited++; if (aPortal.captured) captured++; }); - sExportUniqueJSON=sExportUniqueJSON.slice(0, -2); - sExportUniqueJSON+="\n"+'}'+"\n" + sExportUniqueJSON=JSON.stringify(window.plugin.uniques.uniques,null,4); var dialog = window.dialog({ - title: "Ingress unique visits/cpatures JSON export", - html: 'Find all of your visited/captured portals as JSON below (visited: '+visited+' - vaptured: '+captured+'):' - + '' + title: "Ingress unique visits/captures JSON export", + html: 'Find all of your visited/captured portals as JSON below (visited: '+visited+' - captured: '+captured+'):' + + 'Save' }).parent(); $(".ui-dialog-buttonpane", dialog).remove(); // width first, then centre @@ -46,13 +52,13 @@ function wrapper() { "top": ($(window).height() - dialog.height()) / 2, "left": ($(window).width() - dialog.width()) / 2 }); - $("#idmUnqiuesExport").val(sExportUniqueJSON); + $("#taUCExportImport").val(sExportUniqueJSON); return dialog; } // setup function called by IITC self.setup = function init() { // add controls to toolbox - var link = $("Unique visits/capture export"); + var link = $("UV/UC export/import"); $("#toolbox").append(link); // delete setup to ensure init can't be run again delete self.setup; diff --git a/README.md b/README.md index a9ec72e2d..488579c0b 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,5 @@ This is an IITC plugin to export your unique captures/visits from IITC as a JSON The Uniques plugins and a functioning syncronisation is required, of course. The exported data consists of the Unique Portal ID, visited and captured status, all in JSON format. + +Please note that when saving the list of uniques any existing uniques will never be deleted, only updated. From d1ea5cb2eee63f0ba9c8cd0b8d9c3d3599e69109 Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Sun, 3 Apr 2016 23:55:12 +0200 Subject: [PATCH 05/38] Updated README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 488579c0b..cb3e89293 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # iitc-unique-export -This is an IITC plugin to export your unique captures/visits from IITC as a JSON format. +This is an IITC plugin to export/import your unique captures/visits from/to IITC as a JSON format. The Uniques plugins and a functioning syncronisation is required, of course. -The exported data consists of the Unique Portal ID, visited and captured status, all in JSON format. +The exported/imported data consists of the Unique Portal ID, visited and captured status, all in JSON format. -Please note that when saving the list of uniques any existing uniques will never be deleted, only updated. +Please note that when saving (=importing) the list of uniques any existing uniques will never be deleted, only updated. From d05ef190c6381ce07401c1427f7b7e2250931e92 Mon Sep 17 00:00:00 2001 From: koljanowak Date: Thu, 1 Nov 2018 16:40:29 +0100 Subject: [PATCH 06/38] Fixed include/match header lines for the new Intel URL. (#1) --- IngressUniqueExporter.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IngressUniqueExporter.user.js b/IngressUniqueExporter.user.js index 4efde078d..f82d35f67 100644 --- a/IngressUniqueExporter.user.js +++ b/IngressUniqueExporter.user.js @@ -7,10 +7,10 @@ // @updateURL https://github.com/c-schmitz/iitc-unique-export/raw/master/IngressUniqueExporter.user.js // @downloadURL https://github.com/c-schmitz/iitc-unique-export/raw/master/IngressUniqueExporter.user.js // @description Import/exports the unique capture/visits info to/from a JSON file. This plugin requires the IITC Unique plugin to be installed. -// @include https://www.ingress.com/intel* -// @include http://www.ingress.com/intel* -// @match https://www.ingress.com/intel* -// @match http://www.ingress.com/intel* +// @include https://intel.ingress.com/* +// @include http://intel.ingress.com/* +// @match https://intel.ingress.com/* +// @match http://intel.ingress.com/* // @grant none // ==/UserScript== From 42bff394b96d3fb528f4cf5c889f42b671c87ded Mon Sep 17 00:00:00 2001 From: MysticJay Date: Thu, 16 Jan 2020 20:03:13 +0100 Subject: [PATCH 07/38] Code updated for V0.30 After V0.30 was released the code, that was initially sumbmitted for PR#221 got corrupted. Revamped the branch and fixed the code. --- plugins/bookmarks.js | 66 +++- plugins/draw-tools.js | 129 ++++++- plugins/font-awesome.js | 24 ++ plugins/multi-projects-extension.js | 563 ++++++++++++++++++++++++++++ 4 files changed, 763 insertions(+), 19 deletions(-) create mode 100644 plugins/font-awesome.js create mode 100644 plugins/multi-projects-extension.js diff --git a/plugins/bookmarks.js b/plugins/bookmarks.js index 391c4a73b..ebe91aaae 100644 --- a/plugins/bookmarks.js +++ b/plugins/bookmarks.js @@ -1,12 +1,17 @@ +// @id Bookmarks // @author ZasoGD // @name Bookmarks for maps and portals // @category Controls -// @version 0.3.0 +// @version 0.4.0 // @description Save your favorite Maps and Portals and move the intel map with a click. Works with sync. -/*********************************************************************** +// History *********************************************** +// 0.4.0 MPE-enabled Version (Johtaja) +// 0.3.0 published with IITC-CE 0.30 +// ******************************************************* +/*********************************************************************** HOOKS: - pluginBkmrksEdit: fired when a bookmarks/folder is removed, added or sorted, also when a folder is opened/closed; - pluginBkmrksOpenOpt: fired when the "Bookmarks Options" panel is opened (you can add new options); @@ -16,6 +21,7 @@ // use own namespace for plugin window.plugin.bookmarks = function() {}; + window.plugin.mpeBkmrks = {}; window.plugin.bookmarks.SYNC_DELAY = 5000; @@ -81,7 +87,7 @@ } return result; } - + // Update the localStorage window.plugin.bookmarks.saveStorage = function() { localStorage[plugin.bookmarks.KEY_STORAGE] = JSON.stringify(window.plugin.bookmarks.bkmrksObj); @@ -725,7 +731,7 @@ } window.plugin.bookmarks.dialogLoadListFolders = function(idBox, clickAction, showOthersF, scanType/*0 = maps&portals; 1 = maps; 2 = portals*/) { - var list = JSON.parse(localStorage['plugin-bookmarks']); + var list = JSON.parse(localStorage[window.plugin.bookmarks.KEY_STORAGE]); var listHTML = ''; var foldHTML = ''; var elemGenericFolder = ''; @@ -902,7 +908,7 @@ $('.ui-dialog-autodrawer .ui-dialog-buttonset .ui-button:not(:first)').hide(); } else{ - var portalsList = JSON.parse(localStorage['plugin-bookmarks']); + var portalsList = JSON.parse(localStorage[window.plugin.bookmarks.KEY_STORAGE]); var element = ''; var elementTemp = ''; var elemGenericFolder = ''; @@ -1232,6 +1238,49 @@ plugin.bookmarks.htmlSetbox = '
' + actions + '
'; } +/***************************************************************************************************************************************************************/ +window.plugin.mpeBkmrks.initMPE = function(){ + if(!window.plugin.bookmarks){ return; } + + window.plugin.mpe.setMultiProjects({ + namespace: 'bookmarks2', + title: 'Bookmarks for Maps and Portals', + fa: 'fa-bookmark', + defaultKey: 'plugin-bookmarks', + func_setKey: function(newKey){ + window.plugin.bookmarks.KEY_STORAGE = newKey; + window.plugin.bookmarks.KEY.key = newKey; + }, + func_pre: function(){}, + func_post: function(){ + // Delete all Markers + // window.plugin.bookmarks.resetAllStars(); + for(guid in window.plugin.bookmarks.starLayers){ + var starInLayer = window.plugin.bookmarks.starLayers[guid]; + window.plugin.bookmarks.starLayerGroup.removeLayer(starInLayer); + delete window.plugin.bookmarks.starLayers[guid]; + } + + // Create Storage if not exist + window.plugin.bookmarks.createStorage(); + // Load Storage + window.plugin.bookmarks.loadStorage(); + // window.plugin.bookmarks.saveStorage(); + + // Delete and Regenerate Bookmark Lists + window.plugin.bookmarks.refreshBkmrks(); + + // Add Markers + window.plugin.bookmarks.addAllStars(); + + // Refresh Highlight + window.plugin.bookmarks.highlightRefresh(); + + window.runHooks('pluginBkmrksEdit', {"target": "all", "action": "import"}); + } + }); +} + /***************************************************************************************************************************************************************/ var setup = function() { @@ -1303,4 +1352,11 @@ if (window.plugin.portalslist) { window.plugin.bookmarks.setupPortalsList(); } +// Initilaize MPE-Support only if MPE-Module is available + if(window.plugin.mpe !== undefined){ + window.plugin.mpeBkmrks.initMPE(); + } + } + +// PLUGIN END ////////////////////////////////////////////////////////// diff --git a/plugins/draw-tools.js b/plugins/draw-tools.js index 4da055ef6..4ad7dee6a 100644 --- a/plugins/draw-tools.js +++ b/plugins/draw-tools.js @@ -1,13 +1,21 @@ +// @id draw-tools // @author breunigs // @name Draw tools // @category Draw -// @version 0.7.1 +// @version 0.8.0 // @description Allow drawing things onto the current map so you may plan your next move. +// PLUGIN START //////////////////////////////////////////////////////// +// History *********************************************** +// 0.8.0 MPE-enabled Version (Johtaja) +// 0.7.1 published with IITC-CE 0.30 +// ******************************************************* // use own namespace for plugin window.plugin.drawTools = function() {}; +window.plugin.drawTools.KEY_STORAGE = 'plugin-draw-tools-layer'; + window.plugin.drawTools.getMarkerIcon = function(color) { if (!color) { console.warn('Color is not set (default #a24ac3 will be used)'); @@ -198,15 +206,14 @@ window.plugin.drawTools.save = function() { data.push(item); }); - - localStorage['plugin-draw-tools-layer'] = JSON.stringify(data); + localStorage[window.plugin.drawTools.KEY_STORAGE] = JSON.stringify(data); console.log('draw-tools: saved to localStorage'); } window.plugin.drawTools.load = function() { try { - var dataStr = localStorage['plugin-draw-tools-layer']; + var dataStr = localStorage[window.plugin.drawTools.KEY_STORAGE]; if (dataStr === undefined) return; var data = JSON.parse(dataStr); @@ -303,8 +310,17 @@ window.plugin.drawTools.optAlert = function(message) { } window.plugin.drawTools.optCopy = function() { - if (typeof android !== 'undefined' && android && android.shareString) { - android.shareString(localStorage['plugin-draw-tools-layer']); + if(window.localStorage[window.plugin.drawTools.KEY_STORAGE] === '' || window.localStorage[window.plugin.drawTools.KEY_STORAGE] === undefined){ + dialog({ + html: 'Error! The storage is empty or not exist. Before you try copy/export you draw something.', + width: 250, + dialogClass: 'ui-dialog-drawtools-message', + title: 'Draw Tools Message' + }); + return; + } + if(typeof android !== 'undefined' && android && android.shareString){ + android.shareString(window.localStorage[window.plugin.drawTools.KEY_STORAGE]); } else { var stockWarnings = {}; var stockLinks = []; @@ -347,7 +363,7 @@ window.plugin.drawTools.optCopy = function() { if (stockWarnings.unknown) stockWarnTexts.push('Warning: UNKNOWN ITEM TYPE'); var html = '

Select all and press CTRL+C to copy it.

' - +'' + +'' +'

or, export as a link for the standard intel map (for non IITC users)

' +''; if (stockWarnTexts.length>0) { @@ -363,10 +379,11 @@ window.plugin.drawTools.optCopy = function() { }); } } - window.plugin.drawTools.optExport = function() { - var data = localStorage['plugin-draw-tools-layer']; - window.saveFile(data, 'IITC-drawn-items.json', 'application/json'); + if(window.localStorage[window.plugin.drawTools.KEY_STORAGE] === '' || window.localStorage[window.plugin.drawTools.KEY_STORAGE] === undefined){ + var data = localStorage[window.plugin.drawTools.KEY_STORAGE]; + window.saveFile(data, 'IITC-drawn-items.json', 'application/json'); + } } window.plugin.drawTools.optPaste = function() { @@ -472,10 +489,10 @@ window.plugin.drawTools.optImport = function() { window.plugin.drawTools.optReset = function() { var promptAction = confirm('All drawn items will be deleted. Are you sure?', ''); if(promptAction) { - delete localStorage['plugin-draw-tools-layer']; + localStorage[window.plugin.drawTools.KEY_STORAGE] = '[]'; window.plugin.drawTools.drawnItems.clearLayers(); window.plugin.drawTools.load(); - console.log('DRAWTOOLS: reset all drawn items'); + console.log('DRAWTOOLS: reset all drawn items (OptReset)'); window.plugin.drawTools.optAlert('Reset Successful. '); runHooks('pluginDrawTools', {event: 'clear'}); } @@ -658,11 +675,95 @@ window.plugin.drawTools.boot = function() { } +// --------------------------------------------------------------------------------- +// MPE - MULTI PROJECTS EXTENSION +// --------------------------------------------------------------------------------- +window.plugin.drawTools.mpe = {}; +window.plugin.drawTools.mpe.ui = {}; + +window.plugin.drawTools.mpe.boot = function(){ + window.plugin.drawTools.mpe.initMPE(); + console.log('Drawtools MPE Boot'); +}; + + +window.plugin.drawTools.mpe.initMPE = function(){ + // Not launch the code if the MPE plugin there isn't. + if(!window.plugin.mpe){ return; } + + // The MPE function to set a MultiProjects type + window.plugin.mpe.setMultiProjects({ + namespace: 'drawTools', + title: 'Draw Tools Layer', + // Font awesome css class + fa: 'fa-pencil', + // Function to change a localstorage key + func_setKey: function(newKey){ + window.plugin.drawTools.KEY_STORAGE = newKey; + }, + // Native value of localstorage key + defaultKey: 'plugin-draw-tools-layer', + // This function is run before the localstorage key change + func_pre: function(){}, + // This function is run after the localstorage key change + func_post: function(){ + window.plugin.drawTools.drawnItems.clearLayers(); + window.plugin.drawTools.load(); + console.log('DRAWTOOLS: reset all drawn items (func_post)'); + + if(window.plugin.crossLinks !== undefined){ + if(window.overlayStatus['Cross Links'] === true){ + window.plugin.crossLinks.checkAllLinks(); + + if(window.plugin.destroyedLinks !== undefined){ + if(window.overlayStatus['Destroyed Links Simulator'] === true){ + // window.plugin.destroyedLinks.cross.restoreCrossAll(); + window.plugin.destroyedLinks.cross.removeCrossAll(); + } + } + } + } + + // Code to: + // hide/remove elements from DOM, layers, variables, etc... + // load data from window.localStorage[window.plugin.myPlugin.KEY_STORAGE] + // show/add/draw elements in the DOM, layers, variables, etc... + } + }); +} +/* // not used +window.plugin.drawTools.mpe.setupCSS = function(){ + $("'); } From 50a610f50173d074d185590186b11fa7c75bddcb Mon Sep 17 00:00:00 2001 From: MysticJay Date: Tue, 21 Jul 2020 17:01:31 +0200 Subject: [PATCH 19/38] Adding support for scouted and droned portals Routines and data cretaed. --- plugins/uniques.js | 1103 +++++++++++++++++++++++++------------------- 1 file changed, 636 insertions(+), 467 deletions(-) diff --git a/plugins/uniques.js b/plugins/uniques.js index 672b1bef3..317a5d7af 100644 --- a/plugins/uniques.js +++ b/plugins/uniques.js @@ -1,7 +1,7 @@ // @author 3ch01c // @name Uniques // @category Misc -// @version 0.2.4 +// @version 0.3.0 // @description Allow manual entry of portals visited/captured. Use the 'highlighter-uniques' plugin to show the uniques on the map, and 'sync' to share between multiple browsers or desktop/mobile. It will try and guess which portals you have captured from COMM/portal details, but this will not catch every case. @@ -13,9 +13,9 @@ window.plugin.uniques.SYNC_DELAY = 5000; // maps the JS property names to localStorage keys window.plugin.uniques.FIELDS = { - 'uniques': 'plugin-uniques-data', - 'updateQueue': 'plugin-uniques-data-queue', - 'updatingQueue': 'plugin-uniques-data-updating-queue', + 'uniques': 'plugin-uniques-data', + 'updateQueue': 'plugin-uniques-data-queue', + 'updatingQueue': 'plugin-uniques-data-updating-queue', }; window.plugin.uniques.uniques = {}; @@ -30,543 +30,712 @@ window.plugin.uniques.contentHTML = null; window.plugin.uniques.isHighlightActive = false; 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) { - //FIXME: a virus flip will set the owner of the portal, but doesn't count as a unique capture - 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.updateCheckedAndHighlight(guid); + 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) { + //FIXME: a virus flip will set the owner of the portal, but doesn't count as a unique capture + 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.updateCheckedAndHighlight(guid); } window.plugin.uniques.onPublicChatDataAvailable = function(data) { - var nick = window.PLAYER.nickname; - data.result.forEach(function(msg) { - var plext = msg[2].plext, - markup = plext.markup; - - if(plext.plextType == 'SYSTEM_BROADCAST' - && markup.length==5 - && markup[0][0] == 'PLAYER' - && markup[0][1].plain == nick - && markup[1][0] == 'TEXT' - && markup[1][1].plain == ' deployed an ' - && markup[2][0] == 'TEXT' - && markup[3][0] == 'TEXT' - && markup[3][1].plain == ' Resonator on ' - && markup[4][0] == 'PORTAL') { - // search for "x deployed an Ly Resonator on z" - var portal = markup[4][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalVisited(guid); - } else if(plext.plextType == 'SYSTEM_BROADCAST' - && markup.length==3 - && markup[0][0] == 'PLAYER' - && markup[0][1].plain == nick - && markup[1][0] == 'TEXT' - && markup[1][1].plain == ' deployed a Resonator on ' - && markup[2][0] == 'PORTAL') { - // search for "x deployed a Resonator on z" - var portal = markup[2][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalVisited(guid); - } else if(plext.plextType == 'SYSTEM_BROADCAST' - && markup.length==3 - && markup[0][0] == 'PLAYER' - && markup[0][1].plain == nick - && markup[1][0] == 'TEXT' - && markup[1][1].plain == ' captured ' - && markup[2][0] == 'PORTAL') { - // search for "x captured y" - var portal = markup[2][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalCaptured(guid); - } else if(plext.plextType == 'SYSTEM_BROADCAST' - && markup.length==5 - && markup[0][0] == 'PLAYER' - && markup[0][1].plain == nick - && markup[1][0] == 'TEXT' - && markup[1][1].plain == ' linked ' - && markup[2][0] == 'PORTAL' - && markup[3][0] == 'TEXT' - && markup[3][1].plain == ' to ' - && markup[4][0] == 'PORTAL') { - // search for "x linked y to z" - var portal = markup[2][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalVisited(guid); - } else if(plext.plextType == 'SYSTEM_NARROWCAST' - && markup.length==6 - && markup[0][0] == 'TEXT' - && markup[0][1].plain == 'Your ' - && markup[1][0] == 'TEXT' - && markup[2][0] == 'TEXT' - && markup[2][1].plain == ' Resonator on ' - && markup[3][0] == 'PORTAL' - && markup[4][0] == 'TEXT' - && markup[4][1].plain == ' was destroyed by ' - && markup[5][0] == 'PLAYER') { - // search for "Your Lx Resonator on y was destroyed by z" - var portal = markup[3][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalVisited(guid); - } else if(plext.plextType == 'SYSTEM_NARROWCAST' - && markup.length==5 - && markup[0][0] == 'TEXT' - && markup[0][1].plain == 'Your ' - && markup[1][0] == 'TEXT' - && markup[2][0] == 'TEXT' - && markup[2][1].plain == ' Resonator on ' - && markup[3][0] == 'PORTAL' - && markup[4][0] == 'TEXT' - && markup[4][1].plain == ' has decayed') { - // search for "Your Lx Resonator on y has decayed" - var portal = markup[3][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalVisited(guid); - } else if(plext.plextType == 'SYSTEM_NARROWCAST' - && markup.length==4 - && markup[0][0] == 'TEXT' - && markup[0][1].plain == 'Your Portal ' - && markup[1][0] == 'PORTAL' - && markup[2][0] == 'TEXT' - && (markup[2][1].plain == ' neutralized by ' || markup[2][1].plain == ' is under attack by ') - && markup[3][0] == 'PLAYER') { - // search for "Your Portal x neutralized by y" - // search for "Your Portal x is under attack by y" - var portal = markup[1][1]; - var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); - if(guid) plugin.uniques.setPortalVisited(guid); - } - }); + var nick = window.PLAYER.nickname; + data.result.forEach(function(msg) { + var plext = msg[2].plext, + markup = plext.markup; + + if(plext.plextType == 'SYSTEM_BROADCAST' + && markup.length==5 + && markup[0][0] == 'PLAYER' + && markup[0][1].plain == nick + && markup[1][0] == 'TEXT' + && markup[1][1].plain == ' deployed an ' + && markup[2][0] == 'TEXT' + && markup[3][0] == 'TEXT' + && markup[3][1].plain == ' Resonator on ' + && markup[4][0] == 'PORTAL') { + // search for "x deployed an Ly Resonator on z" + var portal = markup[4][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalVisited(guid); + } else if(plext.plextType == 'SYSTEM_BROADCAST' + && markup.length==3 + && markup[0][0] == 'PLAYER' + && markup[0][1].plain == nick + && markup[1][0] == 'TEXT' + && markup[1][1].plain == ' deployed a Resonator on ' + && markup[2][0] == 'PORTAL') { + // search for "x deployed a Resonator on z" + var portal = markup[2][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalVisited(guid); + } else if(plext.plextType == 'SYSTEM_BROADCAST' + && markup.length==3 + && markup[0][0] == 'PLAYER' + && markup[0][1].plain == nick + && markup[1][0] == 'TEXT' + && markup[1][1].plain == ' captured ' + && markup[2][0] == 'PORTAL') { + // search for "x captured y" + var portal = markup[2][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalCaptured(guid); + } else if(plext.plextType == 'SYSTEM_BROADCAST' + && markup.length==5 + && markup[0][0] == 'PLAYER' + && markup[0][1].plain == nick + && markup[1][0] == 'TEXT' + && markup[1][1].plain == ' linked ' + && markup[2][0] == 'PORTAL' + && markup[3][0] == 'TEXT' + && markup[3][1].plain == ' to ' + && markup[4][0] == 'PORTAL') { + // search for "x linked y to z" + var portal = markup[2][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalVisited(guid); + } else if(plext.plextType == 'SYSTEM_NARROWCAST' + && markup.length==6 + && markup[0][0] == 'TEXT' + && markup[0][1].plain == 'Your ' + && markup[1][0] == 'TEXT' + && markup[2][0] == 'TEXT' + && markup[2][1].plain == ' Resonator on ' + && markup[3][0] == 'PORTAL' + && markup[4][0] == 'TEXT' + && markup[4][1].plain == ' was destroyed by ' + && markup[5][0] == 'PLAYER') { + // search for "Your Lx Resonator on y was destroyed by z" + var portal = markup[3][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalVisited(guid); + } else if(plext.plextType == 'SYSTEM_NARROWCAST' + && markup.length==5 + && markup[0][0] == 'TEXT' + && markup[0][1].plain == 'Your ' + && markup[1][0] == 'TEXT' + && markup[2][0] == 'TEXT' + && markup[2][1].plain == ' Resonator on ' + && markup[3][0] == 'PORTAL' + && markup[4][0] == 'TEXT' + && markup[4][1].plain == ' has decayed') { + // search for "Your Lx Resonator on y has decayed" + var portal = markup[3][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalVisited(guid); + } else if(plext.plextType == 'SYSTEM_NARROWCAST' + && markup.length==4 + && markup[0][0] == 'TEXT' + && markup[0][1].plain == 'Your Portal ' + && markup[1][0] == 'PORTAL' + && markup[2][0] == 'TEXT' + && (markup[2][1].plain == ' neutralized by ' || markup[2][1].plain == ' is under attack by ') + && markup[3][0] == 'PLAYER') { + // search for "Your Portal x neutralized by y" + // search for "Your Portal x is under attack by y" + var portal = markup[1][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalVisited(guid); + } else if(plext.plextType == 'SYSTEM_NARROWCAST' + && markup.length==3 + && markup[0][0] == 'TEXT' + && markup[0][1].plain == 'You claimed Scout Controller on ' + && markup[1][0] == 'PORTAL') { + // search for "You claimed Scout Controller on " + var portal = markup[1][1]; + var guid = window.findPortalGuidByPositionE6(portal.latE6, portal.lngE6); + if(guid) plugin.uniques.setPortalScouted(guid); + } + }); } window.plugin.uniques.updateCheckedAndHighlight = function(guid) { - runHooks('pluginUniquesUpdateUniques', { guid: guid }); - - if (guid == window.selectedPortal) { - - var uniqueInfo = plugin.uniques.uniques[guid], - visited = (uniqueInfo && uniqueInfo.visited) || false, - captured = (uniqueInfo && uniqueInfo.captured) || false; - $('#visited').prop('checked', visited); - $('#captured').prop('checked', captured); - } - - if (window.plugin.uniques.isHighlightActive) { - if (portals[guid]) { - window.setMarkerStyle (portals[guid], guid == selectedPortal); - } - } + runHooks('pluginUniquesUpdateUniques', { guid: guid }); + + if (guid == window.selectedPortal) { + + var uniqueInfo = plugin.uniques.uniques[guid], + visited = (uniqueInfo && uniqueInfo.visited) || false, + captured = (uniqueInfo && uniqueInfo.captured) || false; + scouted = (uniqueInfo && uniqueInfo.scouted) || false; + droned = (uniqueInfo && uniqueInfo.droned) || false; + $('#visited').prop('checked', visited); + $('#captured').prop('checked', captured); + $('#scouted').prop('checked', scouted); + $('#droned').prop('checked', droned); + } + + if (window.plugin.uniques.isHighlightActive) { + if (portals[guid]) { + window.setMarkerStyle (portals[guid], guid == selectedPortal); + } + } } window.plugin.uniques.setPortalVisited = function(guid) { - var uniqueInfo = plugin.uniques.uniques[guid]; - if (uniqueInfo) { - if(uniqueInfo.visited) return; - - uniqueInfo.visited = true; - } else { - plugin.uniques.uniques[guid] = { - visited: true, - captured: false - }; - } - - plugin.uniques.updateCheckedAndHighlight(guid); - plugin.uniques.sync(guid); + var uniqueInfo = plugin.uniques.uniques[guid]; + if (uniqueInfo) { + if(uniqueInfo.visited) return; + + uniqueInfo.visited = true; + } else { + plugin.uniques.uniques[guid] = { + visited: true, + captured: false + }; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); } window.plugin.uniques.setPortalCaptured = function(guid) { - var uniqueInfo = plugin.uniques.uniques[guid]; - if (uniqueInfo) { - if(uniqueInfo.visited && uniqueInfo.captured) return; - - uniqueInfo.visited = true; - uniqueInfo.captured = true; - } else { - plugin.uniques.uniques[guid] = { - visited: true, - captured: true - }; - } - - plugin.uniques.updateCheckedAndHighlight(guid); - plugin.uniques.sync(guid); + var uniqueInfo = plugin.uniques.uniques[guid]; + if (uniqueInfo) { + if(uniqueInfo.visited && uniqueInfo.captured) return; + + uniqueInfo.visited = true; + uniqueInfo.captured = true; + } else { + plugin.uniques.uniques[guid] = { + visited: true, + captured: true + }; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); +} + +window.plugin.uniques.setPortalScouted = function(guid) { + var uniqueInfo = plugin.uniques.uniques[guid]; + if (uniqueInfo) { + if(uniqueInfo.scouted) return; + + uniqueInfo.scouted = true; + } else { + plugin.uniques.uniques[guid] = { + scouted: true, +// captured: false + }; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); +} + +window.plugin.uniques.setPortalDroned = function(guid) { + var uniqueInfo = plugin.uniques.uniques[guid]; + if (uniqueInfo) { + if(uniqueInfo.droned) return; + + uniqueInfo.droned = true; + } else { + plugin.uniques.uniques[guid] = { + droned: true, +// captured: false + }; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); } window.plugin.uniques.updateVisited = function(visited, guid) { - if(guid == undefined) guid = window.selectedPortal; - - var uniqueInfo = plugin.uniques.uniques[guid]; - if (!uniqueInfo) { - plugin.uniques.uniques[guid] = uniqueInfo = { - visited: false, - captured: false - }; - } - - if(visited == uniqueInfo.visited) return; - - if (visited) { - uniqueInfo.visited = true; - } else { // not visited --> not captured - uniqueInfo.visited = false; - uniqueInfo.captured = false; - } - - plugin.uniques.updateCheckedAndHighlight(guid); - plugin.uniques.sync(guid); + if(guid == undefined) guid = window.selectedPortal; + + var uniqueInfo = plugin.uniques.uniques[guid]; + if (!uniqueInfo) { + plugin.uniques.uniques[guid] = uniqueInfo = { + visited: false, + captured: false + }; + } + + if(visited == uniqueInfo.visited) return; + + if (visited) { + uniqueInfo.visited = true; + } else { // not visited --> not captured + uniqueInfo.visited = false; + uniqueInfo.captured = false; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); } window.plugin.uniques.updateCaptured = function(captured, guid) { - if(guid == undefined) guid = window.selectedPortal; - - var uniqueInfo = plugin.uniques.uniques[guid]; - if (!uniqueInfo) { - plugin.uniques.uniques[guid] = uniqueInfo = { - visited: false, - captured: false - }; - } - - if(captured == uniqueInfo.captured) return; - - if (captured) { // captured --> visited - uniqueInfo.captured = true; - uniqueInfo.visited = true; - } else { - uniqueInfo.captured = false; - } - - plugin.uniques.updateCheckedAndHighlight(guid); - plugin.uniques.sync(guid); + if(guid == undefined) guid = window.selectedPortal; + + var uniqueInfo = plugin.uniques.uniques[guid]; + if (!uniqueInfo) { + plugin.uniques.uniques[guid] = uniqueInfo = { + visited: false, + captured: false + }; + } + + if(captured == uniqueInfo.captured) return; + + if (captured) { // captured --> visited + uniqueInfo.captured = true; + uniqueInfo.visited = true; + } else { + uniqueInfo.captured = false; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); +} +// Scouted +window.plugin.uniques.updateScouted = function(scouted, guid) { + if(guid == undefined) guid = window.selectedPortal; + + var uniqueInfo = plugin.uniques.uniques[guid]; + if (!uniqueInfo) { + plugin.uniques.uniques[guid] = uniqueInfo = { + visited: false, + captured: false, + scouted: false, + droned: false + }; + } + + if(scouted == uniqueInfo.scouted) return; + + if (scouted) { + uniqueInfo.scouted = true; +// uniqueInfo.visited = true; + } else { + uniqueInfo.scouted = false; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); +} +// Droned +window.plugin.uniques.updateDroned = function(droned, guid) { + if(guid == undefined) guid = window.selectedPortal; + + var uniqueInfo = plugin.uniques.uniques[guid]; + if (!uniqueInfo) { + plugin.uniques.uniques[guid] = uniqueInfo = { + visited: false, + captured: false, + scouted: false, + droned: false + }; + } + + if(droned == uniqueInfo.droned) return; + + if (droned) { + uniqueInfo.droned = true; +// uniqueInfo.visited = true; + } else { + uniqueInfo.droned = false; + } + + plugin.uniques.updateCheckedAndHighlight(guid); + plugin.uniques.sync(guid); } // stores the gived GUID for sync plugin.uniques.sync = function(guid) { - plugin.uniques.updateQueue[guid] = true; - plugin.uniques.storeLocal('uniques'); - plugin.uniques.storeLocal('updateQueue'); - plugin.uniques.syncQueue(); + plugin.uniques.updateQueue[guid] = true; + plugin.uniques.storeLocal('uniques'); + plugin.uniques.storeLocal('updateQueue'); + plugin.uniques.syncQueue(); } // sync the queue, but delay the actual sync to group a few updates in a single request window.plugin.uniques.syncQueue = function() { - if(!plugin.uniques.enableSync) return; - - clearTimeout(plugin.uniques.syncTimer); - - plugin.uniques.syncTimer = setTimeout(function() { - plugin.uniques.syncTimer = null; - - $.extend(plugin.uniques.updatingQueue, plugin.uniques.updateQueue); - plugin.uniques.updateQueue = {}; - plugin.uniques.storeLocal('updatingQueue'); - plugin.uniques.storeLocal('updateQueue'); - - plugin.sync.updateMap('uniques', 'uniques', Object.keys(plugin.uniques.updatingQueue)); - }, plugin.uniques.SYNC_DELAY); + if(!plugin.uniques.enableSync) return; + + clearTimeout(plugin.uniques.syncTimer); + + plugin.uniques.syncTimer = setTimeout(function() { + plugin.uniques.syncTimer = null; + + $.extend(plugin.uniques.updatingQueue, plugin.uniques.updateQueue); + plugin.uniques.updateQueue = {}; + plugin.uniques.storeLocal('updatingQueue'); + plugin.uniques.storeLocal('updateQueue'); + + plugin.sync.updateMap('uniques', 'uniques', Object.keys(plugin.uniques.updatingQueue)); + }, plugin.uniques.SYNC_DELAY); } //Call after IITC and all plugin loaded window.plugin.uniques.registerFieldForSyncing = function() { - if(!window.plugin.sync) return; - window.plugin.sync.registerMapForSync('uniques', 'uniques', window.plugin.uniques.syncCallback, window.plugin.uniques.syncInitialed); + if(!window.plugin.sync) return; + window.plugin.sync.registerMapForSync('uniques', 'uniques', window.plugin.uniques.syncCallback, window.plugin.uniques.syncInitialed); } //Call after local or remote change uploaded window.plugin.uniques.syncCallback = function(pluginName, fieldName, e, fullUpdated) { - if(fieldName === 'uniques') { - plugin.uniques.storeLocal('uniques'); - // All data is replaced if other client update the data during this client - // offline, - // fire 'pluginUniquesRefreshAll' to notify a full update - if(fullUpdated) { - // a full update - update the selected portal sidebar - if (window.selectedPortal) { - plugin.uniques.updateCheckedAndHighlight(window.selectedPortal); - } - // and also update all highlights, if needed - if (window.plugin.uniques.isHighlightActive) { - resetHighlightedPortals(); - } - - window.runHooks('pluginUniquesRefreshAll'); - return; - } - - if(!e) return; - if(e.isLocal) { - // Update pushed successfully, remove it from updatingQueue - delete plugin.uniques.updatingQueue[e.property]; - } else { - // Remote update - delete plugin.uniques.updateQueue[e.property]; - plugin.uniques.storeLocal('updateQueue'); - plugin.uniques.updateCheckedAndHighlight(e.property); - window.runHooks('pluginUniquesUpdateUniques', {guid: e.property}); - } - } + if(fieldName === 'uniques') { + plugin.uniques.storeLocal('uniques'); + // All data is replaced if other client update the data during this client + // offline, + // fire 'pluginUniquesRefreshAll' to notify a full update + if(fullUpdated) { + // a full update - update the selected portal sidebar + if (window.selectedPortal) { + plugin.uniques.updateCheckedAndHighlight(window.selectedPortal); + } + // and also update all highlights, if needed + if (window.plugin.uniques.isHighlightActive) { + resetHighlightedPortals(); + } + + window.runHooks('pluginUniquesRefreshAll'); + return; + } + + if(!e) return; + if(e.isLocal) { + // Update pushed successfully, remove it from updatingQueue + delete plugin.uniques.updatingQueue[e.property]; + } else { + // Remote update + delete plugin.uniques.updateQueue[e.property]; + plugin.uniques.storeLocal('updateQueue'); + plugin.uniques.updateCheckedAndHighlight(e.property); + window.runHooks('pluginUniquesUpdateUniques', {guid: e.property}); + } + } } //syncing of the field is initialed, upload all queued update window.plugin.uniques.syncInitialed = function(pluginName, fieldName) { - if(fieldName === 'uniques') { - plugin.uniques.enableSync = true; - if(Object.keys(plugin.uniques.updateQueue).length > 0) { - plugin.uniques.syncQueue(); - } - } + if(fieldName === 'uniques') { + plugin.uniques.enableSync = true; + if(Object.keys(plugin.uniques.updateQueue).length > 0) { + plugin.uniques.syncQueue(); + } + } } window.plugin.uniques.storeLocal = function(name) { - var key = window.plugin.uniques.FIELDS[name]; - if(key === undefined) return; + var key = window.plugin.uniques.FIELDS[name]; + if(key === undefined) return; - var value = plugin.uniques[name]; + var value = plugin.uniques[name]; - if(typeof value !== 'undefined' && value !== null) { - localStorage[key] = JSON.stringify(plugin.uniques[name]); - } else { - localStorage.removeItem(key); - } + if(typeof value !== 'undefined' && value !== null) { + localStorage[key] = JSON.stringify(plugin.uniques[name]); + } else { + localStorage.removeItem(key); + } } window.plugin.uniques.loadLocal = function(name) { - var key = window.plugin.uniques.FIELDS[name]; - if(key === undefined) return; + var key = window.plugin.uniques.FIELDS[name]; + if(key === undefined) return; - if(localStorage[key] !== undefined) { - plugin.uniques[name] = JSON.parse(localStorage[key]); - } + if(localStorage[key] !== undefined) { + plugin.uniques[name] = JSON.parse(localStorage[key]); + } } /***************************************************************************************************************************************************************/ /** HIGHLIGHTER ************************************************************************************************************************************************/ /***************************************************************************************************************************************************************/ window.plugin.uniques.highlighter = { - highlight: function(data) { - var guid = data.portal.options.ent[0]; - var uniqueInfo = window.plugin.uniques.uniques[guid]; - - var style = {}; - - if (uniqueInfo) { - if (uniqueInfo.captured) { - // captured (and, implied, visited too) - no highlights - - } else if (uniqueInfo.visited) { - style.fillColor = 'yellow'; - style.fillOpacity = 0.6; - } else { - // we have an 'uniqueInfo' entry for the portal, but it's not set visited or captured? - // could be used to flag a portal you don't plan to visit, so use a less opaque red - style.fillColor = 'red'; - style.fillOpacity = 0.5; - } - } else { - // no visit data at all - style.fillColor = 'red'; - style.fillOpacity = 0.7; - } - - data.portal.setStyle(style); - }, - - setSelected: function(active) { - window.plugin.uniques.isHighlightActive = active; - } + highlight: function(data) { + var guid = data.portal.options.ent[0]; + var uniqueInfo = window.plugin.uniques.uniques[guid]; + + var style = {}; + + if (uniqueInfo) { + if (uniqueInfo.captured) { + // captured (and, implied, visited too) - no highlights + + } else if (uniqueInfo.visited) { + style.fillColor = 'yellow'; + style.fillOpacity = 0.6; + } else { + // we have an 'uniqueInfo' entry for the portal, but it's not set visited or captured? + // could be used to flag a portal you don't plan to visit, so use a less opaque red + style.fillColor = 'red'; + style.fillOpacity = 0.5; + } + } else { + // no visit data at all + style.fillColor = 'red'; + style.fillOpacity = 0.7; + } + + data.portal.setStyle(style); + }, + + setSelected: function(active) { + window.plugin.uniques.isHighlightActive = active; + } } window.plugin.uniques.setupCSS = function() { - $("