diff --git a/plugins/player-tracker.user.js b/plugins/player-tracker.user.js index eca4bf66..38a694ab 100644 --- a/plugins/player-tracker.user.js +++ b/plugins/player-tracker.user.js @@ -68,9 +68,11 @@ window.plugin.playerTracker.setup = function() { var playerPopup = new L.Popup({offset: L.point([0,-20])}); plugin.playerTracker.oms.addListener('click', function(player) { window.renderPortalDetails(player.options.referenceToPortal); - playerPopup.setContent(player.options.desc); - playerPopup.setLatLng(player.getLatLng()); - map.openPopup(playerPopup) + if (player.options.desc) { + playerPopup.setContent(player.options.desc); + playerPopup.setLatLng(player.getLatLng()); + map.openPopup(playerPopup); + } }); plugin.playerTracker.oms.addListener('spiderfy', function(markers) { map.closePopup(); @@ -257,6 +259,8 @@ window.plugin.playerTracker.ago = function(time, now) { } window.plugin.playerTracker.drawData = function() { + var isTouchDev = window.isTouchDevice(); + var gllfe = plugin.playerTracker.getLatLngFromEvent; var polyLineByAgeEnl = [[], [], [], []]; @@ -284,42 +288,45 @@ window.plugin.playerTracker.drawData = function() { polyLineByAgeEnl[ageBucket].push(line); } + // tooltip for marker - no HYML - and not shown on touchscreen devices + var tooltip = isTouchDev ? '' : playerData.nick; + // popup for marker var evtsLength = playerData.events.length; var last = playerData.events[evtsLength-1]; var ago = plugin.playerTracker.ago; var cssClass = playerData.team === 'RESISTANCE' ? 'res' : 'enl'; - var title = '' + playerData.nick + ''; + var popup = '' + playerData.nick + ''; if(window.plugin.guessPlayerLevels !== undefined && window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) { var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid); if(playerLevel !== undefined) { - title += 'Level ' + popup += 'Level ' + playerLevel + ' (guessed)' + ''; } else { - title += 'Level unknown' + popup += 'Level unknown' } } - title += '
' + popup += '
' + ago(last.time, now) + ' ago
' + window.chat.getChatPortalName(last); // show previous data in tooltip if(evtsLength >= 2) { - title += '
 
previous locations:
' + popup += '
 
previous locations:
' + ''; } for(var i = evtsLength - 2; i >= 0 && i >= evtsLength - 10; i--) { var ev = playerData.events[i]; - title += '' + popup += '' + '' + ''; } if(evtsLength >= 2) - title += '
' + ago(ev.time, now) + '
' + ago(ev.time, now) + 'ago' + window.chat.getChatPortalName(ev) + '
'; + popup += ''; // calculate the closest portal to the player var eventPortal = [] @@ -345,11 +352,16 @@ window.plugin.playerTracker.drawData = function() { var icon = playerData.team === 'RESISTANCE' ? new plugin.playerTracker.iconRes() : new plugin.playerTracker.iconEnl(); // as per OverlappingMarkerSpiderfier docs, click events (popups, etc) must be handled via it rather than the standard // marker click events. so store the popup text in the options, then display it in the oms click handler - var m = L.marker(gllfe(last), {icon: icon, referenceToPortal: closestPortal, opacity: absOpacity, desc: title}); + var m = L.marker(gllfe(last), {icon: icon, referenceToPortal: closestPortal, opacity: absOpacity, desc: popup, title: tooltip}); // m.bindPopup(title); m.addTo(playerData.team === 'RESISTANCE' ? plugin.playerTracker.drawnTracesRes : plugin.playerTracker.drawnTracesEnl); plugin.playerTracker.oms.addMarker(m); + + // jQueryUI doesn’t automatically notice the new markers + if (!isTouchDev) { + window.setupTooltips($(m._icon)); + } }); // draw the poly lines to the map