Sha256: ad36c6f3501271298b778d3243bdda8e4b69bf511ede4cfbfb38ea6ef658bc5d
Contents?: true
Size: 1.24 KB
Versions: 7
Compression:
Stored size: 1.24 KB
Contents
Campfire.HTMLExpander = Class.create({ initialize: function(chat) { this.chat = chat; // var messages = this.chat.transcript.messages; // for (var i = 0; i < messages.length; i++) { // this.detectHTML(messages[i]); // } // this.chat.windowmanager.scrollToBottom(); }, detectHTML: function(message) { if (!message.pending() && ['text','paste'].include(message.kind)) { var body = message.bodyElement() var match = body.innerText.match(/^HTML!\s+(.+)$/m); // Some people can't handle this much fun var halt = SOUND_HATERS.include(this.chat.username) && body.innerText.match(/<audio/) if (!halt && match && !body.innerText.match(/<\s*script/)) { body.update(match[1]) } } }, onMessagesInsertedBeforeDisplay: function(messages) { var scrolledToBottom = this.chat.windowmanager.isScrolledToBottom(); for (var i = 0; i < messages.length; i++) { this.detectHTML(messages[i]); } if (scrolledToBottom) { this.chat.windowmanager.scrollToBottom(); } }, onMessageAccepted: function(message, messageID) { this.detectHTML(message); } }); Campfire.Responders.push("HTMLExpander"); window.chat.installPropaneResponder("HTMLExpander", "htmlexpander");
Version data entries
7 entries across 7 versions & 1 rubygems