Fix bugs in user list

* URL is connection-dependent
* Open link in new window so as not to lose work
* Don't show undefined (fixes #302)
This commit is contained in:
John Firebaugh
2012-12-29 11:57:05 -08:00
parent 11b269006c
commit e122552b98
2 changed files with 10 additions and 5 deletions
+4
View File
@@ -138,6 +138,10 @@ iD.Connection = function() {
});
}
connection.userUrl = function(username) {
return apiURL + "/user/" + username;
};
function tileAtZoom(t, distance) {
var power = Math.pow(2, distance);
return [
+6 -5
View File
@@ -49,17 +49,18 @@ window.iD = function(container) {
var users = {},
entities = map.history().graph().intersects(map.extent());
for (var i in entities) {
users[entities[i].user] = true;
if (Object.keys(users).length > 10) break;
if (entities[i].user) {
users[entities[i].user] = true;
if (Object.keys(users).length > 10) break;
}
}
var u = Object.keys(users);
var l = d3.select('#user-list')
.selectAll('a.user-link').data(u);
l.enter().append('a')
.attr('class', 'user-link')
.attr('href', function(d) {
return 'http://api06.dev.openstreetmap.org/user/' + d;
})
.attr('href', function(d) { return connection.userUrl(d); })
.attr('target', '_blank')
.text(String);
l.exit().remove();
}, 1000);