diff --git a/README.md b/README.md index 2290f08..bb871b0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/public/css/default.css b/public/css/default.css index 935ded9..94e5ea8 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -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 */ diff --git a/public/js/cryptalk_modules/$.js b/public/js/cryptalk_modules/$.js index 4577814..6add817 100644 --- a/public/js/cryptalk_modules/$.js +++ b/public/js/cryptalk_modules/$.js @@ -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++) { diff --git a/public/js/cryptalk_modules/client.js b/public/js/cryptalk_modules/client.js index 1ed80b1..337127c 100644 --- a/public/js/cryptalk_modules/client.js +++ b/public/js/cryptalk_modules/client.js @@ -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); }); \ No newline at end of file diff --git a/public/js/cryptalk_modules/console.js b/public/js/cryptalk_modules/console.js index 68c9903..e8b94de 100644 --- a/public/js/cryptalk_modules/console.js +++ b/public/js/cryptalk_modules/console.js @@ -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); }, diff --git a/public/js/cryptalk_modules/settings.js b/public/js/cryptalk_modules/settings.js index 83ce147..0b0a031 100644 --- a/public/js/cryptalk_modules/settings.js +++ b/public/js/cryptalk_modules/settings.js @@ -2,6 +2,8 @@ define({ title: "Cryptalk - Online", + ttl: 600000, + motd: '
\n\n' + '▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▄▄▄ ██▓ ██ ▄█▀ \n' + '▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒████▄ ▓██▒ ██▄█▒ \n' + diff --git a/public/js/cryptalk_modules/templates.js b/public/js/cryptalk_modules/templates.js index ef9f3f6..53d17d8 100644 --- a/public/js/cryptalk_modules/templates.js +++ b/public/js/cryptalk_modules/templates.js @@ -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: '