(function() {
  window.App.Collections.Tweets = new Backbone.Collection({
    model: window.App.Models.Tweet
  });
  window.App.Collections.Tweets.bind("add", function() {});
  window.App.Views.Twitter = Backbone.View.extend({
    el: $('#tweet'),
    initialize: function() {
      _.bindAll(this, 'render', 'getTweets', 'addTweet');
      this.collection = window.App.Collections.Tweets;
      return this.getTweets();
    },
    getTweets: function() {
      var that;
      that = this;
      return jQuery.ajax({
        url: 'http://twitter.com/statuses/user_timeline/owainlewis.json',
        dataType: 'jsonp',
        success: function(data) {
          var message;
          this.data = data;
          message = data[0].text;
          return that.render(message);
        }
      });
    },
    addTweet: function(tweet_to, msg) {
      var tweet;
      this.tweet_to = tweet_to;
      this.msg = msg;
      tweet = new window.App.Models.Tweet;
      tweet.set({
        to: tweet_to,
        message: msg
      });
      return this.collection.add(tweet);
    },
    render: function(tweet) {
      this.tweet = tweet;
      return this.el.html(tweet);
    }
  });
}).call(this);

