Skip to content

Commit

Permalink
Dude
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Dec 25, 2012
1 parent b492cb3 commit df631a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 25 additions & 1 deletion public/application.js
Expand Up @@ -21,6 +21,24 @@ function clearHighlight() {
$('#clear_selection').removeClass("active");
}

function afterUpdate(where) {
where = where || $('#log');

if($('#log').attr('data-channel').indexOf('#teamhacksung') != -1) {
// dude
where.find('.nick').each(function() {
if(this.innerHTML.indexOf("nebkat") != -1) {
var name = this.textContent, newContent = "";
for(var i = 0; i < name.length; i++) {
var color = Math.floor(Math.random(10) * 16) + 1;
newContent += "<span class='nick-" + color + "'>" + name[i] + "</span>";
}
this.innerHTML = newContent;
}
});
}
}

function highlightLine(id) {
$(".log-messages > div").removeClass("highlight");

Expand Down Expand Up @@ -187,11 +205,15 @@ var Live = {

this.eventSource = new EventSource(url);
this.eventSource.onmessage = function(event) {
$('.log-messages').append(event.data);
var newContent = $(event.data);

$('.log-messages').append(newContent);

if(event.lastEventId)
$this.lastId = event.lastEventId;

afterUpdate(newContent);

$this.scroll();
};

Expand Down Expand Up @@ -312,4 +334,6 @@ $(document).ready(function() {

if($('#live_logging').length)
Live.init('#live_logging');

afterUpdate();
});
2 changes: 1 addition & 1 deletion views/channel.haml
@@ -1,4 +1,4 @@
%section#log{:class => 'without-noise'}
%section#log{class: 'without-noise', data: { channel: @channel }}
%aside#log-panel
%label{:for => 'filter'}
Filter:
Expand Down

0 comments on commit df631a6

Please sign in to comment.