Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamez01 committed Nov 21, 2014
1 parent 5ecf1bc commit ceeeba4
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ group :test do
gem 'rspec'
gem 'cinch-test'
gem 'rspec-eventmachine'
gem 'guard'
end
30 changes: 30 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
GEM
remote: https://rubygems.org/
specs:
celluloid (0.16.0)
timers (~> 4.0.0)
cinch (2.1.0)
cinch-test (0.1.1)
cinch (~> 2)
coderay (1.1.0)
diff-lcs (1.2.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.0.3)
ffi (1.9.6)
formatador (0.2.5)
gemoji (2.1.0)
guard (2.8.2)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
pry (>= 0.9.12)
thor (>= 0.18.1)
hitimes (1.2.2)
http_parser.rb (0.6.0)
listen (2.7.12)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
method_source (0.8.2)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rake (0.9.2.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
Expand All @@ -27,6 +52,10 @@ GEM
rspec-mocks (3.1.3)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
slop (3.6.0)
thor (0.19.1)
timers (4.0.1)
hitimes

PLATFORMS
ruby
Expand All @@ -37,6 +66,7 @@ DEPENDENCIES
em-websocket
eventmachine
gemoji
guard
rake
rspec
rspec-eventmachine
15 changes: 15 additions & 0 deletions lib/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ def command_privmsg(args)
privmsg(channel,bot.nick,msg)
end

# handle /msg
def command_msg(args)
target,msg = args.split(/\s/,2)
begin
@bot.Target(target).send(msg)
rescue
systemmsg("error","No such channel or user, #{target}")
end
end

# Handle /me
def command_me(args)

end

# Join a channel
def command_join(args)
return unless args['args']
Expand Down
4 changes: 3 additions & 1 deletion lib/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def images
begin
uri = URI.parse($&)
id = "image#{Time.now.to_i}"
@append << "<div class='media'>" << "<button type='button' class='btn btn-xs btn-info' data-toggle='collapse' data-target='##{id}'>Toggle Image</button>" << "<a target='_blank' href='#{uri}'><img id='#{id}' style='max-width: 250px; max-height: 250px;' src='#{uri}' class='media-object collapse in' /></a></div>" if uri.path =~ /(?:jpg|jpeg|bmp|png|gif|svg)$/
@append << "<div class='media'>" <<
"<button type='button' class='btn btn-xs btn-info' data-toggle='collapse' data-target='##{id}'>Toggle Image</button>" <<
"<a target='_blank' href='#{uri}'><img id='#{id}' style='max-width: 250px; max-height: 250px;' src='#{uri}' class='media-object collapse in' /></a></div>" if uri.path =~ /(?:jpg|jpeg|bmp|png|gif|svg)$/
rescue
end
end
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h4 class="modal-title">Connect to IRC</h4>
<div class="col-md-10 fill scrolldown" id='chatCol'>
<ul class='list-unstyled'>
<div class="tab-content" id='msglist'>
<div role="tabpanel" class="tab-pane fade in" id="tab_server"></div>
<div role="tabpanel" class="tab-pane fade in" id="tab___Server"></div>
</div>
</ul>
</div>
Expand Down
20 changes: 14 additions & 6 deletions public/webric.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var WebRic = {

// Display channel tabs in UI
updateChannels : function() {
$('#channelList').html('<li><a class="btn navbar-btn btn-primary scrolldown" role="tab" data-toggle="tab" href="#tab_server">Server</a></li>');
$('#channelList').html('<li><a class="btn navbar-btn btn-primary scrolldown" role="tab" data-toggle="tab" href="#tab___Server">Server</a></li>');

for(var chan in this.channels) {
$('#channelList').append('<li>' +
Expand All @@ -79,10 +79,11 @@ var WebRic = {
$('#channelList a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
var href=$(e.target).attr('href').substr(5);
var channel=$(e.target).attr('href').substr(5).replace(/^CHANNEL_/,"#");
console.log(href);
WebRic.currentChannel = channel;
$('#button_'+WebRic.sanatizeChannelName(channel)).addClass('btn-primary');
$('#button_'+WebRic.sanatizeChannelName(channel)).removeClass('btn-danger');
if(href != "server") { $('#topicMessage').html(WebRic.channels[channel].topic || "&nbsp;"); }
if(href != "__Server") { $('#topicMessage').html(WebRic.channels[channel].topic || "&nbsp;"); }
WebRic.showNames();
WebRic.scrollDown();
$("#inputBox").focus();
Expand All @@ -97,7 +98,10 @@ var WebRic = {
WebRic.sendCommand('part',{ args: channel });
delete WebRic.channels[channel];
}
WebRic.addLine(channel,"<hr/>");
$(this).parent().parent().prev().children('a').tab('show');
$(this).parent().remove();

});


Expand Down Expand Up @@ -260,12 +264,16 @@ var WebRic = {
var chan = channel || this.currentChannel
$(html).appendTo('#tab_'+this.sanatizeChannelName(chan));
if( ! (chan === this.currentChannel)) {
console.log(chan)
$('#button_'+this.sanatizeChannelName(chan)).removeClass('btn-primary');
$('#button_'+this.sanatizeChannelName(chan)).addClass('btn-danger');
}

console.log(this.window_focus);
// If a private message comes in, make sure tab exists.
if ( ! channel.match(/^#/) && channel != "__Server" ) {
this.addChannel(channel);
}

// Play alert if needed
if ( chan != this.currentChannel || this.window_focus === false) {
$('#notification_sound')[0].play(); // Plays sound.
}
Expand Down Expand Up @@ -307,7 +315,7 @@ var WebRic = {

// show user names in list
showNames : function() {
if(WebRic.currentChannel === 'server') {
if(WebRic.currentChannel === '__Server') {
$('#userlist').html('');
} else {
$('#userlist').html(WebRic.channels[WebRic.currentChannel].users);
Expand Down Expand Up @@ -374,7 +382,7 @@ var WebRic = {
} else {
this.connect();
}
this.currentChannel = "server"; // This will be auto-configured at some point....
this.currentChannel = "__Server"; // This will be auto-configured at some point....
this.updateChannels();

},
Expand Down

0 comments on commit ceeeba4

Please sign in to comment.