From df631a61995f39a3d0db367153247c43e1630606 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 26 Dec 2012 01:40:30 +0400 Subject: [PATCH] Dude --- public/application.js | 26 +++++++++++++++++++++++++- views/channel.haml | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/public/application.js b/public/application.js index 93426dc..4355b68 100644 --- a/public/application.js +++ b/public/application.js @@ -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 += "" + name[i] + ""; + } + this.innerHTML = newContent; + } + }); + } +} + function highlightLine(id) { $(".log-messages > div").removeClass("highlight"); @@ -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(); }; @@ -312,4 +334,6 @@ $(document).ready(function() { if($('#live_logging').length) Live.init('#live_logging'); + + afterUpdate(); }); diff --git a/views/channel.haml b/views/channel.haml index ac8b9a7..dd4d7dd 100644 --- a/views/channel.haml +++ b/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: