Skip to content

Commit

Permalink
Fix #102: code cleanup
Browse files Browse the repository at this point in the history
commit 87fbd27016e1c1cc188f174a1b582d314fff4b16
Author: Michael Weibel <michael.weibel@gmail.com>
Date:   Thu Jul 3 18:31:06 2014 +0200

    Fix console.log -> Candy.Core.log

commit f0e78fbb906f4364b24d5434e1f34d14592576c4
Merge: a13ccaa 4707a74
Author: Michael Weibel <michael.weibel@gmail.com>
Date:   Thu Jul 3 18:29:57 2014 +0200

    Merge branch 'feature/slashcommands_code_cleanup' of github.com:bklang/candy-plugins into bklang-feature/slashcommands_code_cleanup

commit 4707a74
Author: Ben Klang <bklang@mojolingo.com>
Date:   Thu Jul 3 10:13:51 2014 -0400

    Code cleanup for SlashCommands

    * Fixed all JSHint syntax warnings
    * Added LICENSE (MIT)
    * Removed spurious debugging line
  • Loading branch information
mweibel committed Jul 3, 2014
1 parent a13ccaa commit 9b35ba3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
20 changes: 20 additions & 0 deletions slash-commands/LICENSE
@@ -0,0 +1,20 @@
Copyright (C) 2014 Mojo Lingo LLC

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 13 additions & 14 deletions slash-commands/slash-commands.js
Expand Up @@ -63,8 +63,7 @@ CandyShop.SlashCommands = (function(self, Candy, $) {

if (input[0] == '/') {
var match = input.match(/^\/([^\s]+)(?:\s+(.*))?$/m);
if (match != null) {
console.log(match);
if (match !== null) {
var command = match[1];
var data = match[2];

Expand All @@ -78,9 +77,9 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
}
args.message = '';
}
} catch (e) {
} catch (ex) {
// Without an exception catcher, the page will reload and the user will be logged out
console.log(e);
Candy.Core.log(ex);
}
});
};
Expand All @@ -97,11 +96,11 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
var room = args[0];
var password = args[1];

if(typeof room != 'undefined' && room != '') {
if(typeof room != 'undefined' && room !== '') {
if(room.indexOf("@") == -1) {
room += self.defaultConferenceDomain;
}
if (typeof password != 'undefined' && password != '') {
if (typeof password !== 'undefined' && password !== '') {
Candy.Core.Action.Jabber.Room.Join(room, password);
} else {
Candy.Core.Action.Jabber.Room.Join(room);
Expand All @@ -115,7 +114,7 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
*/
self.part = function() {
Candy.Core.Action.Jabber.Room.Leave(self.currentRoom());
}
};

/** Function: topic
* Sets the topic (subject) for the current chat room
Expand All @@ -125,14 +124,14 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
*/
self.topic = function(topic) {
Candy.Core.Action.Jabber.Room.Admin.SetSubject(self.currentRoom(), topic);
}
};

/** Function: clear
* Clear the current room's scrollback
*/
self.clear = function() {
$('.room-pane').filter(':visible').find('.message-pane').empty();
}
$('.room-pane:visible').find('.message-pane').empty();
};

/** Function: available
* Change the current user's XMPP status to "available" with an optional message
Expand All @@ -142,7 +141,7 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
self.available = function(message) {
// TODO: The message field is currently unsupported by Candy.Core.Action.Jabber.Presence
Candy.Core.Action.Jabber.Presence();
}
};

/** Function: away
* Change the current user's XMPP status to "away" with an optional message
Expand All @@ -152,7 +151,7 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
self.away = function(message) {
// TODO: The message field is currently unsupported by Candy.Core.Action.Jabber.Presence
Candy.Core.Action.Jabber.Presence(null, $build('show', 'away'));
}
};

/** Function: dnd
* Change the current user's XMPP status to "dnd" with an optional message
Expand All @@ -162,14 +161,14 @@ CandyShop.SlashCommands = (function(self, Candy, $) {
self.dnd = function(message) {
// TODO: The message field is currently unsupported by Candy.Core.Action.Jabber.Presence
Candy.Core.Action.Jabber.Presence(null, $build('show', 'dnd'));
}
};

/** Function: currentRoom
* Helper function to get the current room
*/
self.currentRoom = function() {
return Candy.View.getCurrent().roomJid;
}
};

return self;
}(CandyShop.SlashCommands || {}, Candy, jQuery));

0 comments on commit 9b35ba3

Please sign in to comment.