Fixes + auto-torch after configurable delay
This commit is contained in:
parent
dd8529bd88
commit
10384f956d
|
@ -12,9 +12,9 @@ Features
|
||||||
|
|
||||||
* Client side AES-256-CBC encryption/decryption (the server is just a messenger)
|
* Client side AES-256-CBC encryption/decryption (the server is just a messenger)
|
||||||
* 256 bit key derived from your passphrase using PBKDF2
|
* 256 bit key derived from your passphrase using PBKDF2
|
||||||
|
* Message is torched after a configurable delay, default is 600s.
|
||||||
* Optional nicknames
|
* Optional nicknames
|
||||||
* Random (UUID v4) channel name generation for less guessability
|
* Quick-links (not recommended!) using http://server/#Room:Passphrase
|
||||||
* Quick-links (not recommended) using http://server/#Room:Passphrase
|
|
||||||
* Super simple setup
|
* Super simple setup
|
||||||
* Notification sounds (mutable)
|
* Notification sounds (mutable)
|
||||||
* Native popup notifications
|
* Native popup notifications
|
||||||
|
|
|
@ -29,7 +29,6 @@ body, html {
|
||||||
.info { color: #99FFFF; }
|
.info { color: #99FFFF; }
|
||||||
.neutral { color: #eeeeee; }
|
.neutral { color: #eeeeee; }
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------*\
|
/*------------------------------------*\
|
||||||
CHAT
|
CHAT
|
||||||
\*------------------------------------*/
|
\*------------------------------------*/
|
||||||
|
@ -47,7 +46,11 @@ body, html {
|
||||||
#chat li {
|
#chat li {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
padding: 2px 15px;
|
padding: 2px 15px;
|
||||||
color: #343434;
|
color: #606006;
|
||||||
|
}
|
||||||
|
|
||||||
|
#chat li .timestamp {
|
||||||
|
color: #808008;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Message types */
|
/* Message types */
|
||||||
|
|
|
@ -152,10 +152,13 @@ define(['fandango', 'websocket', 'aes', 'SHA1'], function (fandango, websocket,
|
||||||
for (var i = 0, len = this.length; i < len; i++) {
|
for (var i = 0, len = this.length; i < len; i++) {
|
||||||
this[0].innerHTML += string;
|
this[0].innerHTML += string;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
proto.first = function () {
|
||||||
|
return this[0];
|
||||||
|
};
|
||||||
|
|
||||||
// Naive implementations of .on()
|
// Naive implementations of .on()
|
||||||
proto.on = function (eventName, callback) {
|
proto.on = function (eventName, callback) {
|
||||||
for (var i = 0, len = this.length; i < len; i++) {
|
for (var i = 0, len = this.length; i < len; i++) {
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
mediator.on('command:help', ...);
|
mediator.on('command:help', ...);
|
||||||
mediator.on('command:nick', ...);
|
mediator.on('command:nick', ...);
|
||||||
mediator.on('command:key', ...);
|
mediator.on('command:key', ...);
|
||||||
mediator.on('command:clear', ...);
|
mediator.on('command:key', ...);
|
||||||
|
mediator.on('command:torch', ...);
|
||||||
mediator.on('command:title', ...);
|
mediator.on('command:title', ...);
|
||||||
|
|
||||||
Emits:
|
Emits:
|
||||||
|
@ -58,6 +59,8 @@ define(
|
||||||
|
|
||||||
clear = function () { mediator.emit('console:clear'); },
|
clear = function () { mediator.emit('console:clear'); },
|
||||||
|
|
||||||
|
setTorch = function (payload) { mediator.emit('console:torch',payload); },
|
||||||
|
|
||||||
nick = function (payload) {
|
nick = function (payload) {
|
||||||
|
|
||||||
// Make sure the nick meets the length requirements
|
// Make sure the nick meets the length requirements
|
||||||
|
@ -87,6 +90,7 @@ define(
|
||||||
mediator.on('command:clear', clear);
|
mediator.on('command:clear', clear);
|
||||||
mediator.on('command:nick', nick);
|
mediator.on('command:nick', nick);
|
||||||
mediator.on('command:key', setKey);
|
mediator.on('command:key', setKey);
|
||||||
|
mediator.on('command:torch', setTorch);
|
||||||
mediator.on('command:title', title);
|
mediator.on('command:title', title);
|
||||||
|
|
||||||
});
|
});
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Accepts:
|
Accepts:
|
||||||
mediator.on('console:clear', clear);
|
mediator.on('console:clear', clear);
|
||||||
|
mediator.on('console:torch', ttl)
|
||||||
mediator.on('console:motd', motd);
|
mediator.on('console:motd', motd);
|
||||||
mediator.on('console:info', info);
|
mediator.on('console:info', info);
|
||||||
mediator.on('console:error', error);
|
mediator.on('console:error', error);
|
||||||
|
@ -42,10 +43,12 @@ define({
|
||||||
commands = {
|
commands = {
|
||||||
post: function (type, text, nick) {
|
post: function (type, text, nick) {
|
||||||
var tpl = templates.post[type],
|
var tpl = templates.post[type],
|
||||||
|
uniqueId = 'msg_' + new Date().getTime() + '_' + Math.round(Math.random()*1000000),
|
||||||
post,
|
post,
|
||||||
data = fandango.merge({}, settings, {
|
data = fandango.merge({}, settings, {
|
||||||
nick: nick,
|
nick: nick,
|
||||||
timestamp: new Date().toLocaleTimeString()
|
timestamp: new Date().toLocaleTimeString(),
|
||||||
|
id: uniqueId
|
||||||
});
|
});
|
||||||
|
|
||||||
data.text = $.template(text, data);
|
data.text = $.template(text, data);
|
||||||
|
@ -54,10 +57,27 @@ define({
|
||||||
// Request a notification
|
// Request a notification
|
||||||
commands.showNotification(type, nick, text);
|
commands.showNotification(type, nick, text);
|
||||||
|
|
||||||
|
// Expire message
|
||||||
|
setTimeout(function() {
|
||||||
|
var parent = components.chat.first(),
|
||||||
|
child = $('#'+uniqueId).first();
|
||||||
|
parent.removeChild(child);
|
||||||
|
}, settings.ttl);
|
||||||
|
|
||||||
// Append the post to the chat DOM element
|
// Append the post to the chat DOM element
|
||||||
components.chat.append(post);
|
components.chat.append(post);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
torch: function (ttl) {
|
||||||
|
var ttl = parseInt(ttl);
|
||||||
|
if( ttl > 0 && ttl < 3600) {
|
||||||
|
mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) );
|
||||||
|
settings.ttl = ttl*1000;
|
||||||
|
} else {
|
||||||
|
mediator.emit('console:error', $.template(templates.messages.torch_not_set) );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
param: function (p) {
|
param: function (p) {
|
||||||
parameters = fandango.merge({}, parameters, p);
|
parameters = fandango.merge({}, parameters, p);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,8 @@ define({
|
||||||
|
|
||||||
title: "Cryptalk - Online",
|
title: "Cryptalk - Online",
|
||||||
|
|
||||||
|
ttl: 600000,
|
||||||
|
|
||||||
motd: '<pre>\n\n' +
|
motd: '<pre>\n\n' +
|
||||||
'▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▄▄▄ ██▓ ██ ▄█▀ \n' +
|
'▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▄▄▄ ██▓ ██ ▄█▀ \n' +
|
||||||
'▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒████▄ ▓██▒ ██▄█▒ \n' +
|
'▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒████▄ ▓██▒ ██▄█▒ \n' +
|
||||||
|
|
|
@ -15,6 +15,9 @@ define({
|
||||||
' /clear Clear on-screen buffer \n' +
|
' /clear Clear on-screen buffer \n' +
|
||||||
' /help This \n' +
|
' /help This \n' +
|
||||||
' /title Set your local page title \n' +
|
' /title Set your local page title \n' +
|
||||||
|
' /torch AfterSeconds Console messages are torched \n' +
|
||||||
|
' after this amount of seconds \n' +
|
||||||
|
' (default 600). \n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
'Room: \n' +
|
'Room: \n' +
|
||||||
' /join RoomId Join a room \n' +
|
' /join RoomId Join a room \n' +
|
||||||
|
@ -42,11 +45,11 @@ define({
|
||||||
// All post templates will have access to the properties in the 'settings' module,
|
// All post templates will have access to the properties in the 'settings' module,
|
||||||
// along with the current nick, room, mute-status and of course the message ('text').
|
// along with the current nick, room, mute-status and of course the message ('text').
|
||||||
post: {
|
post: {
|
||||||
motd: '<li><i class="motd">{text}</i></li>',
|
motd: '<li id="{id}"><i class="motd">{text}</i></li>',
|
||||||
info: '<li><i class="timestamp">[{timestamp}] </i>INF> <i class="info">{text}</i></li>',
|
info: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>INF> <i class="info">{text}</i></li>',
|
||||||
server: '<li><i class="timestamp">[{timestamp}] </i>SRV> <i class="server">{text}</i></li>',
|
server: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>SRV> <i class="server">{text}</i></li>',
|
||||||
error: '<li><i class="timestamp">[{timestamp}] </i>ERR> <i class="error">{text}</i></li>',
|
error: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>ERR> <i class="error">{text}</i></li>',
|
||||||
message: '<li><i class="timestamp">[{timestamp}] </i>MSG> <i class="nick">{nick}></i> <i class="message">{text}</i></li>'
|
message: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>MSG> <i class="nick">{nick}></i> <i class="message">{text}</i></li>'
|
||||||
},
|
},
|
||||||
|
|
||||||
// All message templates will have access to the properties in the 'settings' module,
|
// All message templates will have access to the properties in the 'settings' module,
|
||||||
|
@ -68,6 +71,9 @@ define({
|
||||||
msg_no_key: 'You have to set an encryption key before sending a message. See /help.',
|
msg_no_key: 'You have to set an encryption key before sending a message. See /help.',
|
||||||
leave_from_nowhere: 'How are you supposed to leave, while being nowhere?',
|
leave_from_nowhere: 'How are you supposed to leave, while being nowhere?',
|
||||||
|
|
||||||
|
torch_is_now: 'Messages are now torched after {ttl} seconds.',
|
||||||
|
torch_not_set: 'Invalid torch delay entered, nothing changed. See /help.',
|
||||||
|
|
||||||
title_set: 'The title of this window is now \'{title}\'.',
|
title_set: 'The title of this window is now \'{title}\'.',
|
||||||
|
|
||||||
muted: 'Notifications and sounds are now muted.',
|
muted: 'Notifications and sounds are now muted.',
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
var express = require('express.io'),
|
var express = require('express.io'),
|
||||||
|
|
||||||
app = express();app.http().io();
|
app = express();app.http().io();
|
||||||
|
|
||||||
app.use(express.static(__dirname + '/public'));
|
app.use(express.static(__dirname + '/public'));
|
||||||
|
|
Loading…
Reference in New Issue