aboutsummaryrefslogtreecommitdiffstats
path: root/example/business_card.html
blob: cc45529f55f166a9f02f435461f290586ab5a0ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <script type="text/javascript" src="../lib/underscore/underscore.js"></script>
    <script type="text/javascript" src="../lib/jquery/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="../angular.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
        var scope = angular.compile(document);
        scope.set('tweetFor', function(username){
          scope.set('status', 'fetching');
          scope.set('tweets', []);
          $.getJSON("http://twitter.com/statuses/user_timeline/"+username+".json", function(tweets){
            scope.set('tweets', tweets);
            scope.set('status', "");
            scope.updateView();
          });
          scope.updateView();
        });
        scope.set('tweetHome', function(){
          scope.set('status', 'fetching');
          scope.set('tweets', []);
          $.getJSON("http://twitter.com/statuses/home_timeline.json", function(tweets){
            scope.set('tweets', tweets);
            scope.set('status', "");
            scope.updateView();
          });
          scope.updateView();
        });
        scope.updateView();
        scope.get('tweetHome')();
      });
    </script>
    <style>
    .loading {display: none;}
    .fetching .loading {display: block;}
    </style>
  </head>
  <body ng-class="status">
    <input type="button" ng-action="tweetHome()" value="User Timeline"/> <br/>
    Fetch tweets for:
    <input name="username"/>
    <input type="button" ng-action="tweetFor(username)" value="Fetch"/>
    <hr/>
    <div class="loading">Loading...</div>
    <ul>
     <li ng-repeat="tweet in tweets"><img src="{{tweet.user.profile_image_url}}"/>[{{tweet.user.screen_name}}]: {{tweet.text}}</li>
    </ul>
  </body>
</html>