player tracker: tooltip for desktop with player name - not available on mobile
This commit is contained in:
parent
210a306042
commit
e60c3232c9
@ -68,9 +68,11 @@ window.plugin.playerTracker.setup = function() {
|
|||||||
var playerPopup = new L.Popup({offset: L.point([0,-20])});
|
var playerPopup = new L.Popup({offset: L.point([0,-20])});
|
||||||
plugin.playerTracker.oms.addListener('click', function(player) {
|
plugin.playerTracker.oms.addListener('click', function(player) {
|
||||||
window.renderPortalDetails(player.options.referenceToPortal);
|
window.renderPortalDetails(player.options.referenceToPortal);
|
||||||
|
if (player.options.desc) {
|
||||||
playerPopup.setContent(player.options.desc);
|
playerPopup.setContent(player.options.desc);
|
||||||
playerPopup.setLatLng(player.getLatLng());
|
playerPopup.setLatLng(player.getLatLng());
|
||||||
map.openPopup(playerPopup)
|
map.openPopup(playerPopup);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
plugin.playerTracker.oms.addListener('spiderfy', function(markers) {
|
plugin.playerTracker.oms.addListener('spiderfy', function(markers) {
|
||||||
map.closePopup();
|
map.closePopup();
|
||||||
@ -257,6 +259,8 @@ window.plugin.playerTracker.ago = function(time, now) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.playerTracker.drawData = function() {
|
window.plugin.playerTracker.drawData = function() {
|
||||||
|
var isTouchDev = window.isTouchDevice();
|
||||||
|
|
||||||
var gllfe = plugin.playerTracker.getLatLngFromEvent;
|
var gllfe = plugin.playerTracker.getLatLngFromEvent;
|
||||||
|
|
||||||
var polyLineByAgeEnl = [[], [], [], []];
|
var polyLineByAgeEnl = [[], [], [], []];
|
||||||
@ -284,42 +288,45 @@ window.plugin.playerTracker.drawData = function() {
|
|||||||
polyLineByAgeEnl[ageBucket].push(line);
|
polyLineByAgeEnl[ageBucket].push(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tooltip for marker - no HYML - and not shown on touchscreen devices
|
||||||
|
var tooltip = isTouchDev ? '' : playerData.nick;
|
||||||
|
|
||||||
// popup for marker
|
// popup for marker
|
||||||
var evtsLength = playerData.events.length;
|
var evtsLength = playerData.events.length;
|
||||||
var last = playerData.events[evtsLength-1];
|
var last = playerData.events[evtsLength-1];
|
||||||
var ago = plugin.playerTracker.ago;
|
var ago = plugin.playerTracker.ago;
|
||||||
var cssClass = playerData.team === 'RESISTANCE' ? 'res' : 'enl';
|
var cssClass = playerData.team === 'RESISTANCE' ? 'res' : 'enl';
|
||||||
var title = '<span class="nickname '+ cssClass+'" style="font-weight:bold;">' + playerData.nick + '</span>';
|
var popup = '<span class="nickname '+ cssClass+'" style="font-weight:bold;">' + playerData.nick + '</span>';
|
||||||
|
|
||||||
if(window.plugin.guessPlayerLevels !== undefined &&
|
if(window.plugin.guessPlayerLevels !== undefined &&
|
||||||
window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) {
|
window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) {
|
||||||
var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid);
|
var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid);
|
||||||
if(playerLevel !== undefined) {
|
if(playerLevel !== undefined) {
|
||||||
title += '<span style="font-weight:bold;margin-left:10px;">Level '
|
popup += '<span style="font-weight:bold;margin-left:10px;">Level '
|
||||||
+ playerLevel
|
+ playerLevel
|
||||||
+ ' (guessed)'
|
+ ' (guessed)'
|
||||||
+ '</span>';
|
+ '</span>';
|
||||||
} else {
|
} else {
|
||||||
title += '<span style="font-weight:bold;margin-left:10px;">Level unknown</span>'
|
popup += '<span style="font-weight:bold;margin-left:10px;">Level unknown</span>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
title += '<br>'
|
popup += '<br>'
|
||||||
+ ago(last.time, now) + ' ago<br>'
|
+ ago(last.time, now) + ' ago<br>'
|
||||||
+ window.chat.getChatPortalName(last);
|
+ window.chat.getChatPortalName(last);
|
||||||
// show previous data in tooltip
|
// show previous data in tooltip
|
||||||
if(evtsLength >= 2) {
|
if(evtsLength >= 2) {
|
||||||
title += '<br> <br>previous locations:<br>'
|
popup += '<br> <br>previous locations:<br>'
|
||||||
+ '<table style="border-spacing:0">';
|
+ '<table style="border-spacing:0">';
|
||||||
}
|
}
|
||||||
for(var i = evtsLength - 2; i >= 0 && i >= evtsLength - 10; i--) {
|
for(var i = evtsLength - 2; i >= 0 && i >= evtsLength - 10; i--) {
|
||||||
var ev = playerData.events[i];
|
var ev = playerData.events[i];
|
||||||
title += '<tr align="left"><td>' + ago(ev.time, now) + '</td>'
|
popup += '<tr align="left"><td>' + ago(ev.time, now) + '</td>'
|
||||||
+ '<td>ago</td>'
|
+ '<td>ago</td>'
|
||||||
+ '<td>' + window.chat.getChatPortalName(ev) + '</td></tr>';
|
+ '<td>' + window.chat.getChatPortalName(ev) + '</td></tr>';
|
||||||
}
|
}
|
||||||
if(evtsLength >= 2)
|
if(evtsLength >= 2)
|
||||||
title += '</table>';
|
popup += '</table>';
|
||||||
|
|
||||||
// calculate the closest portal to the player
|
// calculate the closest portal to the player
|
||||||
var eventPortal = []
|
var eventPortal = []
|
||||||
@ -345,11 +352,16 @@ window.plugin.playerTracker.drawData = function() {
|
|||||||
var icon = playerData.team === 'RESISTANCE' ? new plugin.playerTracker.iconRes() : new plugin.playerTracker.iconEnl();
|
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
|
// 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
|
// 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.bindPopup(title);
|
||||||
|
|
||||||
m.addTo(playerData.team === 'RESISTANCE' ? plugin.playerTracker.drawnTracesRes : plugin.playerTracker.drawnTracesEnl);
|
m.addTo(playerData.team === 'RESISTANCE' ? plugin.playerTracker.drawnTracesRes : plugin.playerTracker.drawnTracesEnl);
|
||||||
plugin.playerTracker.oms.addMarker(m);
|
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
|
// draw the poly lines to the map
|
||||||
|
Loading…
x
Reference in New Issue
Block a user