hey

hey

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8/>
  5. <title>Custom Event</title>
  6. <style>
  7. body{width:600px;margin: auto;font-family: sans-serif;text-align: center;}
  8. li {text-align: left;padding-bottom: 1em; }
  9. </style>
  10. </head>
  11.  <body>
  12.  <h2>What Are You Interested In?</h2>
  13. <form action="#">
  14. <p><input type="text" name="q" id="q"></p>
  15. </from>
  16. <ul class="tweets"></ul>
  17. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  18. <script>
  19. (function($){
  20. var obj = $( {} );
  21. $.each({
  22. on:'subscribe',
  23. trigger:'publish',
  24. off:'unsubscribe'
  25. }, function( key,api ){
  26. $[api] = function() {
  27. obj[key].apply ( obj, argruments );
  28. }
  29. });
  30. })(jQuery);

  31. (function($){
  32. var Twitter = {
  33. init: function() {
  34. this.template = '<li>{{tweet}}</li>';
  35. this.query = '@tutspremium';
  36. this.tweets = [];
  37. this.timer;

  38. this.cache();
  39. this.bindEvents();
  40. this.subscriptions();

  41. this.searchInput.val( this.query );
  42. $.publish('twitter/query');
  43.  return this;
  44. },
  45. cache: function() {
  46. this.container = $('ul.tweets');
  47. this.searchInput = $('#q');
  48. },
  49. bindEvents: function () {
  50. this.searchInput.on( 'keyup',this.search );
  51. },
  52. subscriptions:function() {
  53. $.subscribe('twitter/query',this.fetchJSON );
  54. $.subscribe('twitter/query',this.renderResults);
  55. },
  56.  search: function() {
  57.   var self = Twitter,
  58.   input = this;
  59.   clearTimeout( self.timer);
  60.   self.timer = (input.value.length>=3)&& setTimeout(function(){
  61.   self.query = input.value;
  62.   $.publish('twitter/query');
  63.   },400);/* it calls user time*/
  64.  },
  65.   renderResults: function() {
  66.   var self = Twitter,
  67.   frag = [],
  68.   tweet;
  69.  self.container.html(
  70.   $.map( self.tweets, function( obj, index ) {
  71.   var t =
  72.   obj.text.replace(/(http:[^\s]+)/,'<a href="$1"></a>')
  73.   .replace(/@([^\s]+)/,'<a href="http://twitter.com/$1">@$1</a>');
  74.   return self.template.replace(/{{tweet}}/, t)
  75.   }). join('')/* its updates the url*/
  76.   
  77.  window.Twitter = Twitter.init();
  78. })(jQuery);
  79. </script>
  80. </body>
  81. </html>
error:
Uncaught SyntaxError: Unexpected identifier tweets.html:80