Commit 6a49090a authored by JC Brand's avatar JC Brand

Use switch statement instead of ifs

parent fcb0b7bb
...@@ -832,26 +832,27 @@ ...@@ -832,26 +832,27 @@
}, },
sendGroupMessage: function (body) { sendGroupMessage: function (body) {
var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/); var match = body.replace(/^\s*/, "").match(/^\/(.*?)(?: (.*))?$/) || [false];
if (match) { switch (match[1]) {
if (match[1] === "msg") { case 'msg':
// TODO: Private messages // TODO: Private messages
} else if (match[1] === "topic") { break;
case 'topic':
xmppchat.connection.muc.setTopic(this.model.get('jid'), match[2]); xmppchat.connection.muc.setTopic(this.model.get('jid'), match[2]);
break;
} else if (match[1] === "kick") { case 'kick':
xmppchat.connection.muc.kick(this.model.get('jid'), match[2]); xmppchat.connection.muc.kick(this.model.get('jid'), match[2]);
break;
} else if (match[1] === "ban") { case 'ban':
xmppchat.connection.muc.ban(this.model.get('jid'), match[2]); xmppchat.connection.muc.ban(this.model.get('jid'), match[2]);
break;
} else if (match[1] === "op") { case 'op':
xmppchat.connection.muc.op(this.model.get('jid'), match[2]); xmppchat.connection.muc.op(this.model.get('jid'), match[2]);
break;
} else if (match[1] === "deop") { case 'deop':
xmppchat.connection.muc.deop(this.model.get('jid'), match[2]); xmppchat.connection.muc.deop(this.model.get('jid'), match[2]);
break;
} else if (match[1] === "help") { case 'help':
$chat_content = $(this.el).find('.chat-content'); $chat_content = $(this.el).find('.chat-content');
$chat_content.append($('<div class="chat-help"><strong>/help</strong>: Show this menu</div>')); $chat_content.append($('<div class="chat-help"><strong>/help</strong>: Show this menu</div>'));
$chat_content.append($('<div class="chat-help"><strong>/topic</strong>: Set chatroom topic</div>')); $chat_content.append($('<div class="chat-help"><strong>/topic</strong>: Set chatroom topic</div>'));
...@@ -862,11 +863,10 @@ ...@@ -862,11 +863,10 @@
$chat_content.append($('<div class="chat-help"><strong>/deop $user</strong>: Remove messages</div>')); $chat_content.append($('<div class="chat-help"><strong>/deop $user</strong>: Remove messages</div>'));
*/ */
this.scrolldown(); this.scrolldown();
} else { break;
default:
this.last_msgid = xmppchat.connection.muc.groupchat(this.model.get('jid'), body); this.last_msgid = xmppchat.connection.muc.groupchat(this.model.get('jid'), body);
} break;
} else {
this.last_msgid = xmppchat.connection.muc.groupchat(this.model.get('jid'), body);
} }
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment