This commit is contained in:
Hexagon 2021-10-19 20:44:31 +02:00
parent 74bdf5dfef
commit 8ab38d8a41
8 changed files with 21 additions and 15 deletions

View File

@ -3,7 +3,8 @@
"browser": true,
"commonjs": true,
"es6": true,
"node": true
"node": true,
"amd": true
},
"extends": "eslint:recommended",
"parserOptions": {

View File

@ -1,6 +1,6 @@
{
"name": "cryptalk",
"version": "1.2.0",
"version": "1.2.1",
"description": "Encrypted HTML5/Node.JS instant chat",
"main": "server.js",
"subdomain": "cryptalk",

File diff suppressed because one or more lines are too long

View File

@ -55,7 +55,8 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun
*/
exports.template = function (str, map) {
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
// License: https://github.com/janl/mustache.js/blob/master/LICENSE
exports.escapeHtml = (function () {
var pattern = /[&<>"'\/]/g,
var pattern = /[&<>"'/]/g,
entities = {
'&': '&amp;',
'<': '&lt;',

View File

@ -59,7 +59,7 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio
},
torch: function (ttl) {
ttl = parseInt(ttl);
ttl = parseInt(ttl, 10);
if( ttl > 0 && ttl < 3600) {
mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) );
settings.ttl = ttl*1000;

View File

@ -52,8 +52,9 @@ define(['castrato','host','client','console'], function (mediator) {
// Connect to the default host
.emit('command:connect', undefined, function() {
// Join room and set key if a hash in the format #Room:Key has been provided
if ((hash = window.location.hash)) {
parts = hash.slice(1).split(':');
var hash = window.location.hash;
if ( hash ) {
var parts = hash.slice(1).split(':');
if ( parts[0] ) {
mediator.emit('command:join', parts[0]);

View File

@ -9,6 +9,9 @@
Emits:
mediator.on('socket:emit', emit);
eslint no-console: ["error", { allow: ["warn", "error"] }]
*/
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]);
}
} else {
console.log(santized);
mediator.emit('console:error', templates.server.bogus);
}
} else {
console.log(santized);
mediator.emit('console:error', templates.server.bogus);
}
})

View File

@ -21,7 +21,7 @@ io = require('socket.io')(server),
// Listen to port env:PORT or 8080
server.listen(port, function(){
console.log('listening on *:' + port);
console.log('listening on *:' + port); // eslint-disable-line no-console
});
io.on('connection', function(socket) {
@ -51,7 +51,9 @@ io.on('connection', function(socket) {
socket.on('room:count', function () {
if( socket.current_room !== undefined ) {
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) {
socket.emit('message:server', {msg:'person_count', payload: clientsInRoom } );
} else {