[player-tracker] Use new search
This commit is contained in:
parent
5c35cda7b4
commit
4dd877fdb8
@ -27,6 +27,8 @@ window.PLAYER_TRACKER_LINE_COLOUR = '#FF00FD';
|
|||||||
window.plugin.playerTracker = function() {};
|
window.plugin.playerTracker = function() {};
|
||||||
|
|
||||||
window.plugin.playerTracker.setup = function() {
|
window.plugin.playerTracker.setup = function() {
|
||||||
|
$('<style>').prop('type', 'text/css').html('@@INCLUDESTRING:plugins/player-tracker.css@@').appendTo('head');
|
||||||
|
|
||||||
var iconEnlImage = '@@INCLUDEIMAGE:images/marker-green.png@@';
|
var iconEnlImage = '@@INCLUDEIMAGE:images/marker-green.png@@';
|
||||||
var iconEnlRetImage = '@@INCLUDEIMAGE:images/marker-green-2x.png@@';
|
var iconEnlRetImage = '@@INCLUDEIMAGE:images/marker-green-2x.png@@';
|
||||||
var iconResImage = '@@INCLUDEIMAGE:images/marker-blue.png@@';
|
var iconResImage = '@@INCLUDEIMAGE:images/marker-blue.png@@';
|
||||||
@ -511,7 +513,7 @@ window.plugin.playerTracker.centerMapOnUser = function(nick) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(window.isSmartphone()) window.smartphone.mapButton.click();
|
if(window.isSmartphone()) window.show('map');
|
||||||
window.map.setView(position, map.getZoom());
|
window.map.setView(position, map.getZoom());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,22 +524,39 @@ window.plugin.playerTracker.onNicknameClicked = function(info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.playerTracker.onGeoSearch = function(search) {
|
window.plugin.playerTracker.onSearchResultSelected = function(result, event) {
|
||||||
if (/^@/.test(search)) {
|
if(window.isSmartphone()) window.show('map');
|
||||||
plugin.playerTracker.centerMapOnUser(search.replace(/^@/, ''));
|
|
||||||
return false;
|
// if the user moved since the search was started, check if we have a new set of data
|
||||||
}
|
if(false === window.plugin.playerTracker.centerMapOnUser(result.title))
|
||||||
|
map.setView(result.position);
|
||||||
|
|
||||||
|
if(event.type == 'dblclick')
|
||||||
|
map.setZoom(17);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
window.plugin.playerTracker.onSearch = function(query) {
|
||||||
|
var term = query.term.toLowerCase();
|
||||||
|
|
||||||
|
$.each(plugin.playerTracker.stored, function(nick, data) {
|
||||||
|
if(nick.toLowerCase().indexOf(term) === -1) return;
|
||||||
|
|
||||||
|
var event = data.events[data.events.length - 1];
|
||||||
|
|
||||||
|
query.addResult({
|
||||||
|
title: nick,
|
||||||
|
description: data.team.substr(0,3) + ', last seen ' + unixTimeToDateTimeString(event.time),
|
||||||
|
position: plugin.playerTracker.getLatLngFromEvent(event),
|
||||||
|
onSelected: window.plugin.playerTracker.onSearchResultSelected,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.playerTracker.setupUserSearch = function() {
|
window.plugin.playerTracker.setupUserSearch = function() {
|
||||||
$('<style>').prop('type', 'text/css').html('@@INCLUDESTRING:plugins/player-tracker.css@@').appendTo('head');
|
|
||||||
|
|
||||||
addHook('nicknameClicked', window.plugin.playerTracker.onNicknameClicked);
|
addHook('nicknameClicked', window.plugin.playerTracker.onNicknameClicked);
|
||||||
addHook('geoSearch', window.plugin.playerTracker.onGeoSearch);
|
addHook('search', window.plugin.playerTracker.onSearch);
|
||||||
|
|
||||||
var geoSearch = $('#geosearch');
|
|
||||||
var beforeEllipsis = /(.*)…/.exec(geoSearch.attr('placeholder'))[1];
|
|
||||||
geoSearch.attr('placeholder', beforeEllipsis + ' or @player…');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user