Permalink
Browse files

Screamcasts plugin

  • Loading branch information...
1 parent f07af52 commit e8afc595ccd96c2d5ae32829621d65ce88daca55 Pablo Villalba committed Nov 11, 2012
Showing with 23 additions and 0 deletions.
  1. +1 −0 index.html
  2. +22 −0 js/plugins/screamcasts.js
View
@@ -38,6 +38,7 @@
<script src="js/plugins/presence.js"></script>
<script src="js/plugins/recent_messages.js"></script>
<script src="js/plugins/responsive.js"></script>
+ <script src="js/plugins/screamcasts.js"></script>
<script src="js/plugins/sound.js"></script>
<script src="js/plugins/tabs.js"></script>
<script src="js/plugins/title_message_count.js"></script>
@@ -0,0 +1,22 @@
+/**
+ * Embed GIF web animations from screamcasts.com
+ */
+
+(function () {
+
+ var image_expression = /(^https?:\/\/screamcasts.com[^\s]+\.gif$)/gi;
+
+ /**
+ * Receives event from the logger adding a message
+ */
+ Talker.client.on("log:add", function (e) {
+ var image_match = e.content.match(image_expression);
+
+ if (image_match) {
+ $(e.element).find("span.content").html("<img src='" + image_match[0] + "' style='width:100px; height:100px;'>");
+ Talker.log.scrollToBottom();
+ }
+ });
+
+}());
+

0 comments on commit e8afc59

Please sign in to comment.