Commit e9f491ce authored by Corentin Mors's avatar Corentin Mors
Browse files

Generate random ID if no username selected

parent 3138ed62
...@@ -305,7 +305,7 @@ $(function() { ...@@ -305,7 +305,7 @@ $(function() {
var view = new View({ var view = new View({
center: [47, 2.4], center: [266736 ,5955932],
zoom: 5 zoom: 5
}); });
...@@ -357,6 +357,7 @@ $(function() { ...@@ -357,6 +357,7 @@ $(function() {
// Get rid of legacy login system // Get rid of legacy login system
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
username = urlParams.get('u'); username = urlParams.get('u');
if(username == null) username = makeid();
socket.emit('add user', username); socket.emit('add user', username);
$loginPage.fadeOut(); $loginPage.fadeOut();
$chatPage.show(); $chatPage.show();
...@@ -430,6 +431,16 @@ $(function() { ...@@ -430,6 +431,16 @@ $(function() {
mylayer.getSource().refresh(); mylayer.getSource().refresh();
} }
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
}); });
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment