This commit is contained in:
j 2016-01-26 16:06:07 +05:30
parent ddf94ef736
commit 13bfab3407

View file

@ -191,6 +191,11 @@ window.app = (function() {
if (!user) { if (!user) {
user = createUser(data); user = createUser(data);
} }
user.coords = data.coords;
if (user.name != data.name) {
user.name = data.name;
updateUserList();
}
var options = { var options = {
title: user.name, title: user.name,
icon: L.icon({ icon: L.icon({
@ -200,7 +205,6 @@ window.app = (function() {
}) })
}) })
}; };
user.coords = data.coords;
if (user.marker) { if (user.marker) {
map.removeLayer(user.marker); map.removeLayer(user.marker);
} }
@ -221,6 +225,20 @@ window.app = (function() {
div.innerHTML = user.name; div.innerHTML = user.name;
div.style.background = 'rgb(' + user.color.join(', ') + ')'; div.style.background = 'rgb(' + user.color.join(', ') + ')';
div.style.top = '8px' div.style.top = '8px'
div.onclick = function() {
if (!user.id) {
var name = prompt("What is your name?", username) || 'Anonymous';
localStorage.username = username = name;
update({
name: username,
color: color,
coords: coords
});
updateUserList();
} else if (user.coords) {
map.setView(user.coords, zoomLevel);
}
}
list.appendChild(div); list.appendChild(div);
}); });
if (userlist) { if (userlist) {