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)
|
||||
* 256 bit key derived from your passphrase using PBKDF2
|
||||
* Message is torched after a configurable delay, default is 600s.
|
||||
* 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
|
||||
* Notification sounds (mutable)
|
||||
* Native popup notifications
|
||||
|
|
|
@ -26,10 +26,9 @@ body, html {
|
|||
|
||||
.good { color: #99FF99; }
|
||||
.bad { color: #ff7777; }
|
||||
.info { color:#99FFFF; }
|
||||
.info { color: #99FFFF; }
|
||||
.neutral { color: #eeeeee; }
|
||||
|
||||
|
||||
/*------------------------------------*\
|
||||
CHAT
|
||||
\*------------------------------------*/
|
||||
|
@ -47,7 +46,11 @@ body, html {
|
|||
#chat li {
|
||||
white-space: pre;
|
||||
padding: 2px 15px;
|
||||
color: #343434;
|
||||
color: #606006;
|
||||
}
|
||||
|
||||
#chat li .timestamp {
|
||||
color: #808008;
|
||||
}
|
||||
|
||||
/* Message types */
|
||||
|
|
|
@ -152,10 +152,13 @@ define(['fandango', 'websocket', 'aes', 'SHA1'], function (fandango, websocket,
|
|||
for (var i = 0, len = this.length; i < len; i++) {
|
||||
this[0].innerHTML += string;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
proto.first = function () {
|
||||
return this[0];
|
||||
};
|
||||
|
||||
// Naive implementations of .on()
|
||||
proto.on = function (eventName, callback) {
|
||||
for (var i = 0, len = this.length; i < len; i++) {
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
mediator.on('command:help', ...);
|
||||
mediator.on('command:nick', ...);
|
||||
mediator.on('command:key', ...);
|
||||
mediator.on('command:clear', ...);
|
||||
mediator.on('command:key', ...);
|
||||
mediator.on('command:torch', ...);
|
||||
mediator.on('command:title', ...);
|
||||
|
||||
Emits:
|
||||
|
@ -58,6 +59,8 @@ define(
|
|||
|
||||
clear = function () { mediator.emit('console:clear'); },
|
||||
|
||||
setTorch = function (payload) { mediator.emit('console:torch',payload); },
|
||||
|
||||
nick = function (payload) {
|
||||
|
||||
// Make sure the nick meets the length requirements
|
||||
|
@ -87,6 +90,7 @@ define(
|
|||
mediator.on('command:clear', clear);
|
||||
mediator.on('command:nick', nick);
|
||||
mediator.on('command:key', setKey);
|
||||
mediator.on('command:torch', setTorch);
|
||||
mediator.on('command:title', title);
|
||||
|
||||
});
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
Accepts:
|
||||
mediator.on('console:clear', clear);
|
||||
mediator.on('console:torch', ttl)
|
||||
mediator.on('console:motd', motd);
|
||||
mediator.on('console:info', info);
|
||||
mediator.on('console:error', error);
|
||||
|
@ -42,10 +43,12 @@ define({
|
|||
commands = {
|
||||
post: function (type, text, nick) {
|
||||
var tpl = templates.post[type],
|
||||
uniqueId = 'msg_' + new Date().getTime() + '_' + Math.round(Math.random()*1000000),
|
||||
post,
|
||||
data = fandango.merge({}, settings, {
|
||||
nick: nick,
|
||||
timestamp: new Date().toLocaleTimeString()
|
||||
timestamp: new Date().toLocaleTimeString(),
|
||||
id: uniqueId
|
||||
});
|
||||
|
||||
data.text = $.template(text, data);
|
||||
|
@ -54,10 +57,27 @@ define({
|
|||
// Request a notification
|
||||
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
|
||||
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) {
|
||||
parameters = fandango.merge({}, parameters, p);
|
||||
},
|
||||
|
|
|
@ -2,6 +2,8 @@ define({
|
|||
|
||||
title: "Cryptalk - Online",
|
||||
|
||||
ttl: 600000,
|
||||
|
||||
motd: '<pre>\n\n' +
|
||||
'▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▄▄▄ ██▓ ██ ▄█▀ \n' +
|
||||
'▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒████▄ ▓██▒ ██▄█▒ \n' +
|
||||
|
|
|
@ -15,6 +15,9 @@ define({
|
|||
' /clear Clear on-screen buffer \n' +
|
||||
' /help This \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' +
|
||||
'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,
|
||||
// along with the current nick, room, mute-status and of course the message ('text').
|
||||
post: {
|
||||
motd: '<li><i class="motd">{text}</i></li>',
|
||||
info: '<li><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>',
|
||||
error: '<li><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>'
|
||||
motd: '<li id="{id}"><i class="motd">{text}</i></li>',
|
||||
info: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>INF> <i class="info">{text}</i></li>',
|
||||
server: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>SRV> <i class="server">{text}</i></li>',
|
||||
error: '<li id="{id}"><i class="timestamp">[{timestamp}] </i>ERR> <i class="error">{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,
|
||||
|
@ -68,6 +71,9 @@ define({
|
|||
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?',
|
||||
|
||||
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}\'.',
|
||||
|
||||
muted: 'Notifications and sounds are now muted.',
|
||||
|
|
Loading…
Reference in New Issue