better urls, no more #

This commit is contained in:
ian ramzy 2020-03-24 19:27:09 -04:00
parent 73c724fff3
commit 9f4a204fe9
2 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,4 @@
if (!location.hash) {
if (window.location.pathname === "/") {
// Generate random room name if needed
var adjectives = ["small", "big", "large", "smelly", "new", "happy", "shiny", "old", "clean", "nice", "bad", "cool",
"hot", "cold", "warm", "hungry", "slow", "fast", "red", "white", "black", "blue", "green"];
@ -7,9 +7,11 @@ if (!location.hash) {
"couch", "towel"];
var adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
var noun = nouns[Math.floor(Math.random() * nouns.length)];
location.hash = adjective + noun
noun = noun.charAt(0).toUpperCase() + noun.substring(1);
adjective = adjective.charAt(0).toUpperCase() + adjective.substring(1);
window.location.href = window.location.href + adjective + noun;
}
const roomHash = location.hash.substring(1);
const roomHash = window.location.pathname;
function logIt(message, error) {
// console.log(message);

View File

@ -18,6 +18,11 @@ app.get('/landing', function (req, res) {
res.sendFile(path.join(public, 'landing/landing.html'));
});
app.get('/*', function (req, res) {
res.sendFile(path.join(public, 'chat.html'));
});
function log(msg, room) {
console.log(room + ": " + msg)
}