diff --git a/src/app.js b/src/app.js index 757b748..f903755 100644 --- a/src/app.js +++ b/src/app.js @@ -42,8 +42,8 @@ app.get('/', (req, res) => generateNewRoom(req, res, 'lobby')); app.get('/:roomId', (req, res) => { const stripName = (name) => { const chatName = name.toLowerCase().replace(/[^A-Za-z0-9]/g, '-'); - if (chatName.length >= 25) { - return chatName.substr(0, 25); + if (chatName.length >= 50) { + return chatName.substr(0, 50); } return chatName; diff --git a/src/js/app.js b/src/js/app.js index f938675..68530fb 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -4,6 +4,7 @@ import WindowHandler from './window'; import Chat from './chat'; import moment from 'moment'; import sanitizeHtml from 'sanitize-html'; +import uuid from 'uuid'; import he from 'he'; export default class App { @@ -18,8 +19,8 @@ export default class App { stripName(name) { const chatName = name.replace('/','').toLowerCase().replace(/[^A-Za-z0-9]/g, '-'); - if (chatName.length >= 25) { - const limitedChatName = chatName.substr(0, 25); + if (chatName.length >= 50) { + const limitedChatName = chatName.substr(0, 50); window.history.replaceState({}, limitedChatName, `/${limitedChatName}`); return `/${limitedChatName}`; } @@ -37,7 +38,6 @@ export default class App { $('input.share-text').click(() => { $(this).focus(); $(this).select(); - $(this).setSelectionRange(0, 9999); }); const windowHandler = new WindowHandler(this._darkwire, this._socket, this._chat); @@ -259,12 +259,22 @@ export default class App { } this._chat.log(moment().format('MMMM Do YYYY, h:mm:ss a'), {info: true}); + $('#roomName').text(this._roomId); + $('#chatNameModal').text(this._roomId); + this._darkwire.updateUsername(username).then((socketData) => { this._chat.chatPage.show(); this._chat.inputMessage.focus(); this._socket.emit('add user', socketData); }); + + $('#newRoom').on('click', (e) => { + e.preventDefault(); + const newWindow = window.open(); + newWindow.opener = null; + newWindow.location = window.location.protocol + '//' + window.location.host + '/' + uuid.v4().replace(/-/g,''); + }); } addParticipantsMessage(data) { diff --git a/src/views/index.mustache b/src/views/index.mustache index 653688f..769cb8a 100644 --- a/src/views/index.mustache +++ b/src/views/index.mustache @@ -39,7 +39,7 @@