You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2012/01/17 15:17:23 UTC

svn commit: r1232419 - /incubator/wookie/trunk/widgets/templates/widgets/twitter/scripts/twidget_controller.js

Author: scottbw
Date: Tue Jan 17 14:17:23 2012
New Revision: 1232419

URL: http://svn.apache.org/viewvc?rev=1232419&view=rev
Log:
"Linkify" @screen_names in template example Twitter widget

Modified:
    incubator/wookie/trunk/widgets/templates/widgets/twitter/scripts/twidget_controller.js

Modified: incubator/wookie/trunk/widgets/templates/widgets/twitter/scripts/twidget_controller.js
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/widgets/twitter/scripts/twidget_controller.js?rev=1232419&r1=1232418&r2=1232419&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/widgets/twitter/scripts/twidget_controller.js (original)
+++ incubator/wookie/trunk/widgets/templates/widgets/twitter/scripts/twidget_controller.js Tue Jan 17 14:17:23 2012
@@ -17,12 +17,31 @@
 
 /*
  * Change created times into friendly strings like "2 minutes ago"
- * using the TimeAgo JQuery plugin. We trigger this on document
+ * using the TimeAgo JQuery plugin. Also "linkify" any @screenname
+ * found in tweets
+ *
+ * We trigger this on document
  * load and whenever the results are updated.
  */
 $(document).ready(function() {
  $('abbr.timeago').timeago();
+ linkify();
  $('body').bind('results_updated', function() {
    $('abbr.timeago').timeago();
+   linkify();
+ });
+
 });
-});
\ No newline at end of file
+
+
+/*
+ * Replace @screen_name in tweets with links that update the results with that user's timeline
+ */
+function linkify(){
+  $('.tweet_text').each(function(){
+     var html = $(this).text().replace(/(^|)@(\w+)/gi, function (s) {
+        return '<a href="#" onclick="${widget.shortname}_browse_controller.search(\''+s+'\')">'+s+'</a>';
+     });
+     $(this).html(html);
+  });
+}
\ No newline at end of file