Skip to content

Instantly share code, notes, and snippets.

@qrush
Forked from tmm1/README.md
Created February 10, 2011 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qrush/820805 to your computer and use it in GitHub Desktop.
Save qrush/820805 to your computer and use it in GitHub Desktop.
apply in: /Applications/Propane.app/Contents/Resources
diff --git a/enhancer.js b/enhancer.js
index 8cd9411..1ab7598 100644
--- a/enhancer.js
+++ b/enhancer.js
@@ -58,9 +58,29 @@ if (window.propane) {
Campfire.PropaneResponder = Class.create({
initialize: function(chat) {
+ var self = this
this.chat = chat;
+
+ chat.transcript.element.childElements().each(function(elem){
+ var msg = new Campfire.Message(chat, elem)
+ self.addGravatar(msg)
+ })
+
+ this.chat.layoutmanager.layout();
+ this.chat.windowmanager.scrollToBottom();
+ },
+ addGravatar: function(message) {
+ if (message.actsLikeTextMessage()) {
+ var author = message.authorElement();
+
+ if (author.visible()) {
+ author.insert({after: '<img alt="'+message.author()+'" width="24" height="24" align="top" style="margin-left: 5px; border-radius:3px" src="http://ralphatar.heroku.com/?id='+this.authorID(message)+'&author='+message.author()+'">'});
+ author.hide()
+ message.bodyCell.insert({top: '<strong>' + message.author() + '</strong>'})
+ }
+ }
},
-
+
authorID: function(message) {
if (Element.hasClassName(message.element, 'you'))
return this.chat.userID;
@@ -116,6 +136,11 @@ if (window.propane) {
}
window.propane.messageInserted(message.id(), this.authorID(message), authorText, message.kind, body);
+
+ this.addGravatar(message);
+
+ if (this.chat.scrollToBottom)
+ this.chat.windowmanager.scrollToBottom();
}
},
hideEnterLeave: function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment