Skip to content

Commit

Permalink
Added emoticons and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove committed Apr 12, 2012
1 parent 3584aba commit 26440cc
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 8 deletions.
Binary file added app/assets/images/emoticons/alone.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/awwyea.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/badass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/bitchplease.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/cereal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/challenge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/fuckyeah.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/ilied.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/megusta.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/notbad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/okay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/omgface.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/pokerface.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/rageguy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/seriously.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/sweetjesus.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/truestory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/emoticons/youdontsay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
37 changes: 29 additions & 8 deletions app/assets/javascripts/backbone/plugins/emoticons.js.coffee
Original file line number Diff line number Diff line change
@@ -1,24 +1,45 @@
class Kandan.Plugins.Emoticons

@options:
regex: /\([a-zA-Z]\)/g
regex: /\([a-zA-Z]+\)/g
template: _.template '''
<img class="emoticon-embed" src="/assets/<%= emoticon %>" height="20" width="20" />
<img class="emoticon-embed" src="/assets/emoticons/<%= emoticon %>" height="20" width="20" />
'''


@emoticons: {
"(yuno)": "y_u_no.jog"
"(alone)" : "alone.jpg",
"(awwyea)" : "awwyea.jpg",
"(badass)" : "badass.png",
"(bitchplease)" : "bitchplease.jpg",
"(cereal)" : "cereal.jpg",
"(challenge)" : "challenge.jpg",
"(fuckyeah)" : "fuckyeah.jpg",
"(ilied)" : "ilied.jpg",
"(megusta)" : "megusta.jpg",
"(notbad)" : "notbad.jpg",
"(okay)" : "okay.jpg",
"(omgface)" : "omgface.jpg",
"(pokerface)" : "pokerface.jpg",
"(rageguy)" : "rageguy.jpg",
"(seriously)" : "seriously.jpg",
"(sweetjesus)" : "sweetjesus.jpg",
"(truestory)" : "truestory.jpg",
"(youdontsay)" : "youdontsay.png",
"(yuno)" : "yuno.jpg"
}

@init: ()->
Kandan.Modifiers.register @regex, (message, state)=>
matches = message.content.match(@regex)
Kandan.Modifiers.register @options.regex, (message, state) =>
matches = message.content.match(@options.regex)
for match in _.unique(matches)
emoticon = @emoticons[match]
search = new Regex(match, 'g')
needle = match.replace('(', '\\(').replace(')', '\\)')
search = new RegExp(needle, 'g')
console.log(search)
replacement = @options.template({ emoticon: emoticon })
message.content.replace(search, replacement) if emoticon
return Kandan.Helpers.Activities.build_from_base_template(message)
message.content = message.content.replace(search, replacement) if emoticon
console.log(message.content)
return Kandan.Helpers.Activities.buildFromBaseTemplate(message)

# Kandan.Plugins.register "Kandan.Plugins.Emoticons"

0 comments on commit 26440cc

Please sign in to comment.