Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed /topic handler #194

Merged
merged 2 commits into from

2 participants

@SpenserJ

Problem:
/topic This is a test # Would change the topic of channel "This"
to "is", and ignore the rest
/topic #Channel This is a test # Would change the topic of channel
"#Channel" to "This" and ignore the rest
Resolution:
If args[0] starts with # or &, a channel has been provided. Set the
channel's name to args.shift(), and the topic to args.join(' ')
If args[0] does not start with # or &, set the active channel's
topic to args.join(' ')

@SpenserJ SpenserJ Fixed /topic handler
Problem:
/topic This is a test # Would change the topic of channel "This"
    to "is", and ignore the rest
/topic #Channel This is a test # Would change the topic of channel
    "#Channel" to "This" and ignore the rest
Resolution:
If args[0] starts with # or &, a channel has been provided. Set the
    channel's name to args.shift(), and the topic to args.join(' ')
If args[0] does not start with # or &, set the active channel's
    topic to args.join(' ')
51eaec4
assets/js/client.js
@@ -425,11 +425,11 @@ $(function() {
});
irc.commands.add('topic', function(args){
- if (args[1]) {
- irc.socket.emit('topic', {name: args[0], topic: args[1]});
+ if (args[0].indexOf('#') == 0 || args[0].indexOf('&') == 0) {
@thedjpetersen Owner

Just the same style comment: ===, and maybe a comment on what this comparison is doing then it looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@thedjpetersen thedjpetersen merged commit b6ce807 into thedjpetersen:master
@thedjpetersen

Thanks!

@SpenserJ SpenserJ deleted the SpenserJ:fix_topic_command_handler branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 24, 2012
  1. @SpenserJ

    Fixed /topic handler

    SpenserJ authored
    Problem:
    /topic This is a test # Would change the topic of channel "This"
        to "is", and ignore the rest
    /topic #Channel This is a test # Would change the topic of channel
        "#Channel" to "This" and ignore the rest
    Resolution:
    If args[0] starts with # or &, a channel has been provided. Set the
        channel's name to args.shift(), and the topic to args.join(' ')
    If args[0] does not start with # or &, set the active channel's
        topic to args.join(' ')
  2. @SpenserJ
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 assets/js/client.js
View
9 assets/js/client.js
@@ -425,11 +425,12 @@ $(function() {
});
irc.commands.add('topic', function(args){
- if (args[1]) {
- irc.socket.emit('topic', {name: args[0], topic: args[1]});
- } else {
+ // If args[0] starts with # or &, a topic name has been provided
+ if (args[0].indexOf('#') === 0 || args[0].indexOf('&') === 0) {
+ irc.socket.emit('topic', {name: args.shift(), topic: args.join(' ')});
+ } else { // Otherwise, assume we're changing the current channel's topic
irc.socket.emit('topic', {name: irc.chatWindows.getActive().get('name'),
- topic: args[0]});
+ topic: args.join(' ')});
}
});
Something went wrong with that request. Please try again.