Cleanup
This commit is contained in:
parent
74bdf5dfef
commit
8ab38d8a41
|
@ -3,7 +3,8 @@
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"commonjs": true,
|
"commonjs": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"node": true
|
"node": true,
|
||||||
|
"amd": true
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cryptalk",
|
"name": "cryptalk",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"description": "Encrypted HTML5/Node.JS instant chat",
|
"description": "Encrypted HTML5/Node.JS instant chat",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"subdomain": "cryptalk",
|
"subdomain": "cryptalk",
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -55,7 +55,8 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun
|
||||||
*/
|
*/
|
||||||
exports.template = function (str, map) {
|
exports.template = function (str, map) {
|
||||||
return str && str.replace(/{(\w+)}/gi, function(outer, inner) {
|
return str && str.replace(/{(\w+)}/gi, function(outer, inner) {
|
||||||
return map.hasOwnProperty(inner) ? map[inner] : outer /* '' */;
|
return Object.prototype.hasOwnProperty.call(map, inner) ? map[inner] : outer /* '' */;
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun
|
||||||
// Code: https://github.com/janl/mustache.js/blob/master/mustache.js#L43
|
// Code: https://github.com/janl/mustache.js/blob/master/mustache.js#L43
|
||||||
// License: https://github.com/janl/mustache.js/blob/master/LICENSE
|
// License: https://github.com/janl/mustache.js/blob/master/LICENSE
|
||||||
exports.escapeHtml = (function () {
|
exports.escapeHtml = (function () {
|
||||||
var pattern = /[&<>"'\/]/g,
|
var pattern = /[&<>"'/]/g,
|
||||||
entities = {
|
entities = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
|
|
|
@ -59,7 +59,7 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio
|
||||||
},
|
},
|
||||||
|
|
||||||
torch: function (ttl) {
|
torch: function (ttl) {
|
||||||
ttl = parseInt(ttl);
|
ttl = parseInt(ttl, 10);
|
||||||
if( ttl > 0 && ttl < 3600) {
|
if( ttl > 0 && ttl < 3600) {
|
||||||
mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) );
|
mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) );
|
||||||
settings.ttl = ttl*1000;
|
settings.ttl = ttl*1000;
|
||||||
|
|
|
@ -52,14 +52,15 @@ define(['castrato','host','client','console'], function (mediator) {
|
||||||
// Connect to the default host
|
// Connect to the default host
|
||||||
.emit('command:connect', undefined, function() {
|
.emit('command:connect', undefined, function() {
|
||||||
// Join room and set key if a hash in the format #Room:Key has been provided
|
// Join room and set key if a hash in the format #Room:Key has been provided
|
||||||
if ((hash = window.location.hash)) {
|
var hash = window.location.hash;
|
||||||
parts = hash.slice(1).split(':');
|
if ( hash ) {
|
||||||
|
var parts = hash.slice(1).split(':');
|
||||||
|
|
||||||
if (parts[0]) {
|
if ( parts[0] ) {
|
||||||
mediator.emit('command:join', parts[0]);
|
mediator.emit('command:join', parts[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts[1]) {
|
if ( parts[1] ) {
|
||||||
mediator.emit('command:key', parts[1]);
|
mediator.emit('command:key', parts[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
Emits:
|
Emits:
|
||||||
mediator.on('socket:emit', emit);
|
mediator.on('socket:emit', emit);
|
||||||
|
|
||||||
|
eslint no-console: ["error", { allow: ["warn", "error"] }]
|
||||||
|
|
||||||
*/
|
*/
|
||||||
define(['$', 'castrato','settings','templates','hosts','window'], function ($, mediator, settings, templates, hostconfig) {
|
define(['$', 'castrato','settings','templates','hosts','window'], function ($, mediator, settings, templates, hostconfig) {
|
||||||
|
|
||||||
|
@ -168,11 +171,9 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m
|
||||||
mediator.emit('console:server', templates.server[sanitized]);
|
mediator.emit('console:server', templates.server[sanitized]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(santized);
|
|
||||||
mediator.emit('console:error', templates.server.bogus);
|
mediator.emit('console:error', templates.server.bogus);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(santized);
|
|
||||||
mediator.emit('console:error', templates.server.bogus);
|
mediator.emit('console:error', templates.server.bogus);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -21,7 +21,7 @@ io = require('socket.io')(server),
|
||||||
|
|
||||||
// Listen to port env:PORT or 8080
|
// Listen to port env:PORT or 8080
|
||||||
server.listen(port, function(){
|
server.listen(port, function(){
|
||||||
console.log('listening on *:' + port);
|
console.log('listening on *:' + port); // eslint-disable-line no-console
|
||||||
});
|
});
|
||||||
|
|
||||||
io.on('connection', function(socket) {
|
io.on('connection', function(socket) {
|
||||||
|
@ -51,7 +51,9 @@ io.on('connection', function(socket) {
|
||||||
socket.on('room:count', function () {
|
socket.on('room:count', function () {
|
||||||
if( socket.current_room !== undefined ) {
|
if( socket.current_room !== undefined ) {
|
||||||
let clientsInRoom = 0;
|
let clientsInRoom = 0;
|
||||||
if (io.sockets.adapter.rooms.has(socket.current_room)) clientsInRoom = io.sockets.adapter.rooms.get(socket.current_room).size
|
if( io.sockets.adapter.rooms.has(socket.current_room) ) {
|
||||||
|
clientsInRoom = io.sockets.adapter.rooms.get(socket.current_room).size;
|
||||||
|
}
|
||||||
if( clientsInRoom > 1) {
|
if( clientsInRoom > 1) {
|
||||||
socket.emit('message:server', {msg:'person_count', payload: clientsInRoom } );
|
socket.emit('message:server', {msg:'person_count', payload: clientsInRoom } );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue