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

Version Path
caveat_patch_kids-0.0.8 scripts/caveat_patch_kids/unsupported/display_html.js
caveat_patch_kids-0.0.7 scripts/caveat_patch_kids/unsupported/display_html.js
caveat_patch_kids-0.0.5 scripts/caveat_patch_kids/unsupported/display_html.js
caveat_patch_kids-0.0.4 scripts/caveat_patch_kids/unsupported/display_html.js
caveat_patch_kids-0.0.3 scripts/caveat_patch_kids/unsupported/display_html.js
caveat_patch_kids-0.0.2 scripts/caveat_patch_kids/unsupported/display_html.js
caveat_patch_kids-0.0.1 scripts/caveat_patch_kids/unsupported/display_html.js