diff --git a/static/js/app.js b/static/js/app.js index 1329476..01d7c0a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -191,6 +191,11 @@ window.app = (function() { if (!user) { user = createUser(data); } + user.coords = data.coords; + if (user.name != data.name) { + user.name = data.name; + updateUserList(); + } var options = { title: user.name, icon: L.icon({ @@ -200,7 +205,6 @@ window.app = (function() { }) }) }; - user.coords = data.coords; if (user.marker) { map.removeLayer(user.marker); } @@ -221,6 +225,20 @@ window.app = (function() { div.innerHTML = user.name; div.style.background = 'rgb(' + user.color.join(', ') + ')'; 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); }); if (userlist) {