2011-10-07 18:27:49 +00:00
|
|
|
function noop() {}
|
|
|
|
|
$(document).ready(function() {
|
2010-03-16 21:38:56 +00:00
|
|
|
function xhr(method, url, data, callback){
|
2011-10-07 18:27:49 +00:00
|
|
|
jQuery.getJSON(url, function() {
|
2010-03-16 21:38:56 +00:00
|
|
|
callback.apply(this, arguments);
|
|
|
|
|
scope.updateView();
|
2010-03-23 22:16:44 +00:00
|
|
|
});
|
2010-03-16 21:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-16 21:48:11 +00:00
|
|
|
var resourceFactory = new ResourceFactory(xhr);
|
2010-03-16 21:38:56 +00:00
|
|
|
|
|
|
|
|
var Tweeter = resourceFactory.route("http://twitter.com/statuses/:service:username.json", {}, {
|
|
|
|
|
home: {method:'GET', params: {service:'home_timeline'}, isArray:true },
|
|
|
|
|
user: {method:'GET', params: {service:'user_timeline/'}, isArray:true }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2010-01-23 23:54:58 +00:00
|
|
|
var scope = window.scope = angular.compile(document, {
|
|
|
|
|
location:angular.startUrlWatcher()
|
|
|
|
|
});
|
2010-01-19 01:56:08 +00:00
|
|
|
|
|
|
|
|
function fetchTweets(username){
|
2010-03-16 21:38:56 +00:00
|
|
|
return username ? Tweeter.user({username: username}) : Tweeter.home();
|
2010-01-19 01:56:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scope.set('fetchTweets', fetchTweets);
|
|
|
|
|
scope.set('users', [
|
2010-03-23 22:16:44 +00:00
|
|
|
{screen_name:'mhevery', name:'Mi\u0161ko Hevery',
|
|
|
|
|
notes:'Author of <angular/> http://www.getangular.com.',
|
2010-01-20 15:08:57 +00:00
|
|
|
profile_image_url:'http://a3.twimg.com/profile_images/54360179/Me_-_Small_Banner_normal.jpg'},
|
2010-03-23 22:16:44 +00:00
|
|
|
{screen_name:'abrons', name:'Adam Abrons',
|
|
|
|
|
notes:'Author of <angular/> & Ruby guru see: http://www.angularjs.org.',
|
2010-01-20 15:08:57 +00:00
|
|
|
profile_image_url:'http://media.linkedin.com/mpr/mpr/shrink_80_80/p/2/000/005/0a8/044278d.jpg'}
|
2010-01-19 01:56:08 +00:00
|
|
|
]);
|
|
|
|
|
scope.init();
|
|
|
|
|
});
|