From 3caaaf5164d9e33efe0b667a8882901ae322bb40 Mon Sep 17 00:00:00 2001 From: Xelio Date: Wed, 27 Mar 2013 11:39:29 +0800 Subject: [PATCH] Plugin Keys On Map: Show message when the plugin disabled. --- plugins/keys-on-map.user.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/keys-on-map.user.js b/plugins/keys-on-map.user.js index 54e0a5f3..02658585 100644 --- a/plugins/keys-on-map.user.js +++ b/plugins/keys-on-map.user.js @@ -28,8 +28,10 @@ window.plugin.keysOnMap.keyLayerGroup = new L.LayerGroup(); // Use portal add and remove event to control render of keys window.plugin.keysOnMap.portalAdded = function(data) { // Disable if Plugin Keys is not there - if(!plugin.keys) + if(!plugin.keys) { + plugin.keysOnMap.disableMessage(); return; + } data.portal.on('add', function() { plugin.keysOnMap.renderKey(this.options.guid, this.getLatLng()); @@ -42,9 +44,10 @@ window.plugin.keysOnMap.portalAdded = function(data) { window.plugin.keysOnMap.keyUpdate = function(data) { // Disable if Plugin Keys is not there - if(!plugin.keys) + if(!plugin.keys) { + plugin.keysOnMap.disableMessage(); return; - + } var portal = window.portals[data.guid]; if(!portal) return; var latLng = portal.getLatLng(); @@ -80,6 +83,13 @@ window.plugin.keysOnMap.removeKey = function(guid) { } } +window.plugin.keysOnMap.disableMessage = function() { + if(!plugin.keysOnMap.messageShown) { + alert('Plugin "Keys On Map" need plugin "Keys" to run!'); + plugin.keysOnMap.messageShown = true; + } +} + var setup = function() { $("