From 13bfab3407dcf8bf54b1a1eea50956b524c457fc Mon Sep 17 00:00:00 2001 From: j Date: Tue, 26 Jan 2016 16:06:07 +0530 Subject: [PATCH] set name --- static/js/app.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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) {