diff --git a/src/app.js b/src/app.js index 8c5d2e7..0c0fa4b 100644 --- a/src/app.js +++ b/src/app.js @@ -24,7 +24,7 @@ const sessionMiddleware = session({ saveUninitialized: true }); -var rooms = []; +let rooms = []; io.use(function(socket, next) { sessionMiddleware(socket.request, socket.request.res, next); @@ -44,9 +44,7 @@ function generateNewRoom(req, res, id) { console.log('generating new room'); room.on('empty', function() { - console.log('room empty', room._id); rooms = _.without(rooms, _.findWhere(rooms, {_id: room._id})); - }); return res.redirect(`/${id}`); @@ -64,7 +62,7 @@ app.get('/loaderio-6f94612a3fa71ff98b23eecfcca2de6c.html', (req, res) => { app.get('/:roomId', (req, res) => { const roomId = req.params.roomId || false; - let roomExists = _.findWhere(rooms, {_id: roomId}) ? true : false; + let roomExists = _.findWhere(rooms, {_id: roomId}) || false; if (roomExists) { return res.render('index', {username: shortid.generate()}); diff --git a/src/public/main.js b/src/public/main.js index 0b8fa70..fb0e024 100644 --- a/src/public/main.js +++ b/src/public/main.js @@ -1,3 +1,5 @@ +var fs = window.RequestFileSystem || window.webkitRequestFileSystem; + $(function() { var FADE_TIME = 150; // ms var TYPING_TIMER_LENGTH = 400; // ms @@ -41,6 +43,16 @@ $(function() { // Sets the client's username function setUsername () { username = window.username; + // warn not incognitor + if (!fs) { + console.log('no fs'); + } else { + fs(window.TEMPORARY, + 100, + log.bind(log, "!!WARNING!! : Your browser is not in incognito mode! : !!WARNING!!"), + log.bind(log, "Your browser is in incognito mode.")); + } + // If the username is valid if (username) { $chatPage.show();