lib/jschat/http/public/javascripts/app/ui/commands.js in jschat-0.1.2 vs lib/jschat/http/public/javascripts/app/ui/commands.js in jschat-0.1.5

- old
+ new

@@ -7,13 +7,16 @@ '/help': function() { var help = []; Display.add_message('<strong>JsChat Help</strong> &mdash; Type the following commands into the message field:', 'help') help.push(['/clear', 'Clears messages']); + help.push(['/join #room_name', 'Joins a room']); + help.push(['/part #room_name', 'Leaves a room. Leave room_name blank for the current room']); help.push(['/lastlog', 'Shows recent activity']); help.push(['/names', 'Refreshes the names list']); help.push(['/name new_name', 'Changes your name']); + help.push(['/quit', 'Quit']); help.push(['/emotes', 'Shows available emotes']); $A(help).each(function(options) { var help_text = '<span class="command">#{command}</span><span class="command_help">#{text}</span>'.interpolate({ command: options[0], text: options[1]}); Display.add_message(help_text, 'help'); }); @@ -49,7 +52,25 @@ }); }, '/names': function() { JsChat.Request.get('/names', function(t) { this.displayMessages(t.responseText); }.bind(this)); + }, + + '/(join)\\s+(.*)': function() { + var room = arguments[0][2]; + this.validateAndJoinRoom(room); + }, + + '/(part|leave)': function() { + this.partRoom(PageHelper.currentRoom()); + }, + + '/(part|leave)\\s+(.*)': function() { + var room = arguments[0][2]; + this.partRoom(room); + }, + + '/quit': function() { + window.location = '/quit'; } };