Sha256: 8ecd26ba883a19328dc0710b63a6d1d1a7b234a923645aa62d40c7fb6da1131e

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

Campfire.RdioExpander = Class.create({
  initialize: (chat) ->
    this.chat = chat
    this.detectRdioURL(message) for message in chat.transcript.messages

  detectRdioURL: (message) ->
    if !message.pending() and message.kind == 'text'
      links = message.bodyElement().select('a:not(image)')
      for link in links
        href = link.getAttribute('href')
        match = href.match(/^http:\/\/(rd\.io\/x\/\w*)$/)
        if match
          rdioHref = "rdio://" + match[1]
          link.setAttribute('href', rdioHref)

  onMessagesInsertedBeforeDisplay: (messages) ->
    this.detectRdioURL(message) for message in messages

  onMessageAccepted: (message, messageID) ->
    this.detectRdioURL(message)
})

Campfire.Responders.push("RdioExpander")
window.chat.installPropaneResponder("RdioExpander", "rdioexpander")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caveat_patch_kids-0.0.5 scripts/caveat_patch_kids/link_to_rdio_app.coffee