diff --git a/plugins/portal-history-ornaments.js b/plugins/portal-history-ornaments.js index 682397142..b047b0c10 100644 --- a/plugins/portal-history-ornaments.js +++ b/plugins/portal-history-ornaments.js @@ -11,13 +11,9 @@ window.plugin.portalHistoryOrnaments = portalsHistory; // Exposed functions -portalsHistory.makeButton = makeButton; -portalsHistory.toggleHistory = toggleHistory; -portalsHistory.removePortalFromMap = removePortalFromMap; -portalsHistory.addToPortalMap = addToPortalMap; -portalsHistory.toggleDisplayMode = toggleDisplayMode; -portalsHistory.createIcons = createIcons; -portalsHistory.drawAllFlags = drawAllFlags; +portalsHistory.toggleHistory = toggleHistory; // Button +portalsHistory.toggleDisplayMode = toggleDisplayMode; // dialog +portalsHistory.drawAllFlags = drawAllFlags; // hooked to 'mapDataRefreshEnd' var KEY_SETTINGS = "plugin-portal-history-flags"; @@ -62,8 +58,6 @@ function toggleHistory(keepUIbutton) { } }; -// ----------------------------------------------------------------------------------------- -// New Style Ornaments (by @Eisfrei) function svgToIcon (str, s) { var url = ("data:image/svg+xml," + encodeURIComponent(str)).replace(/#/g, '%23'); return new L.Icon({ @@ -74,22 +68,6 @@ function svgToIcon (str, s) { }) } -function removePortalFromMap (data) { - if (!data.portal._historyLayer) { - return; - } - portalsHistory.layerGroup.removeLayer(data.portal._historyLayer); -} - -function addToPortalMap (data) { - var tileParams = window.getCurrentZoomTileParameters ? window.getCurrentZoomTileParameters() : window.getMapZoomTileParameters(); - if (tileParams.level === 0) { - drawPortalFlags(data.portal); - } else { - portalsHistory.removePortalFromMap(data); - } -} - function loadSettings() { try { portalsHistory.settings = JSON.parse(localStorage[KEY_SETTINGS]); @@ -198,7 +176,7 @@ function drawPortalFlags (portal) { function drawAllFlags () { portalsHistory.layerGroup.clearLayers(); - portalsHistory.createIcons(); + createIcons(); //IITC.me support: getCurrentZoomTileParameters is iitc.app only; iitc.me function is: getMapZoomTileParameters var tileParams = window.getCurrentZoomTileParameters ? window.getCurrentZoomTileParameters() : window.getMapZoomTileParameters(); if (tileParams.level !== 0) { @@ -222,7 +200,6 @@ function getSVGString (size, color, parts, offset) { } // ----------------------------------------------------------------------------------------- var setup = function () { - loadSettings(); var checkedCircle = ' '; var emptyCircle = ' '; @@ -244,16 +221,16 @@ var setup = function () { $('head').append(style); - makeButton (); - // New Style Ornaments (by @EisFrei) - +// Initialization + loadSettings(); portalsHistory.layerGroup = new L.LayerGroup(); window.addLayerGroup('Portal History', portalsHistory.layerGroup, false); -// window.addHook('portalAdded', portalsHistory.addToPortalMap); -// window.addHook('portalRemoved', portalsHistory.removePortalFromMap); +// Hooks window.addHook('mapDataRefreshEnd', portalsHistory.drawAllFlags); -// window.map.on('zoom', portalsHistory.drawAllFlags); + +// UI additions + makeButton (); $('#toolbox').append('Portal History'); }