1+ <html>
2+ <head>
3+ <link rel="stylesheet" href="css/base.css"/>
4+ <link rel="stylesheet" href="plugins/twitter/custom.css"/>
5+ </head>
6+ <body>
7+
8+
9+ <!-- ============================================ -->
10+ <!-- CHART CONTAINER -->
11+ <div id="display1" class="chartContainer splitflap">
12+
13+ <!-- parameters -->
14+ <div class="chartPrefs" style="display:none;">
15+ <input type="hidden" name="id" value="<?php echo $ _GET ["id " ] ?> " /> <!-- the type of data you want from the service -->
16+ </div>
17+
18+ <ul id="chart1" class="chart">
19+
20+ <h1>@<?php echo $ _GET ["id " ] ?> </h1>
21+
22+ <!-- Header: 30px/char, 15px/separator, 120px/logo -->
23+ <div class="header" style="width:120px;margin-left:0px;">Time</div>
24+ <div class="header" style="width:120px;margin-left:0px;">Tweet</div>
25+
26+ <!-- rows will be placed here dynamically from #row_template -->
27+
28+ </ul>
29+
30+ </div>
31+ <!-- END CHART CONTAINER -->
32+ <!-- ============================================ -->
33+
34+ <script type="text/javascript" src="js/jquery-1.7.1-min.js"></script>
35+ <script type="text/javascript" src="js/underscore.js"></script>
36+ <script type="text/javascript" src="js/backbone.js"></script>
37+ <script type="text/javascript" src="js/split-flap.js"></script>
38+ <script type="text/javascript" src="plugins/twitter/custom.js"></script>
39+
40+ <!-- ============================================ -->
41+ <!-- ROW TEMPLATE -->
42+ <script type="text/template" id="row_template">
43+ <li class="row">
44+ <div class="group timestamp"> <!-- timestamp -->
45+ <div class="number"><span></span></div>
46+ <div class="number"><span></span></div>
47+ <div class="number"><span></span></div>
48+ <div class="number"><span></span></div>
49+ </div>
50+ <div class="group text"> <!-- tweet -->
51+ <div class="full"><span></span></div>
52+ <div class="full"><span></span></div>
53+ <div class="full"><span></span></div>
54+ <div class="full"><span></span></div>
55+ <div class="full"><span></span></div>
56+ <div class="full"><span></span></div>
57+ <div class="full"><span></span></div>
58+ <div class="full"><span></span></div>
59+ <div class="full"><span></span></div>
60+ <div class="full"><span></span></div>
61+
62+ <div class="full"><span></span></div>
63+ <div class="full"><span></span></div>
64+ <div class="full"><span></span></div>
65+ <div class="full"><span></span></div>
66+ <div class="full"><span></span></div>
67+ <div class="full"><span></span></div>
68+ <div class="full"><span></span></div>
69+ <div class="full"><span></span></div>
70+ <div class="full"><span></span></div>
71+ <div class="full"><span></span></div>
72+
73+ <div class="full"><span></span></div>
74+ <div class="full"><span></span></div>
75+ <div class="full"><span></span></div>
76+ <div class="full"><span></span></div>
77+ <div class="full"><span></span></div>
78+ <div class="full"><span></span></div>
79+ <div class="full"><span></span></div>
80+ <div class="full"><span></span></div>
81+ <div class="full"><span></span></div>
82+ <div class="full"><span></span></div>
83+
84+ <div class="full"><span></span></div>
85+ <div class="full"><span></span></div>
86+ <div class="full"><span></span></div>
87+ <div class="full"><span></span></div>
88+ <div class="full"><span></span></div>
89+ <div class="full"><span></span></div>
90+ <div class="full"><span></span></div>
91+ <div class="full"><span></span></div>
92+ <div class="full"><span></span></div>
93+ <div class="full"><span></span></div>
94+ </div>
95+ </li>
96+ </script>
97+ <!-- END ROW TEMPLATE -->
98+ <!-- ============================================ -->
99+
100+ <script type="text/javascript">
101+
102+ // This View generates the empty markup for the rows
103+ // It is only called once, at document.ready()
104+ var Board = Backbone.View.extend({
105+ el: $("#chart1"),
106+ template: _.template($('#row_template').html()),
107+ initialize: function(){
108+ this.render();
109+ this.el.find(".row").each(function(){
110+ sf.display.initRow($(this));
111+ })
112+ },
113+ render: function() {
114+ this.el.find(".row").remove();
115+ for(var i=0;i<(sf.local.numRows?sf.local.numRows:3);i++){
116+ this.el.append(this.template());
117+ }
118+ return this;
119+ }
120+ });
121+
122+ // This Collection is used to hold the datset for this board.
123+ var Rows = Backbone.Collection.extend({
124+ update: function(container){
125+ this.fetch({
126+ success: function(response){
127+ sf.display.loadSequentially(response.toJSON(), container) // TODO: should this know about this method?
128+ }
129+ });
130+ },
131+ parse: function(json){
132+ return(sf.plugins.twitter.formatData(json)); // normalize this data
133+ }
134+ });
135+
136+ // Utility method to clear the board
137+ $("#clear").click(function(){
138+ sf.display.clear($('#display1'));
139+ });
140+
141+ $(document).ready(function() {
142+
143+ // Set the number of rows to create (defaults to 3).
144+ sf.local.numRows = 13;
145+
146+ // generate the empty rows markup (a backbone View)
147+ var board = new Board;
148+
149+ var container = $("#display1");
150+ var id = container.find("input[name=id]").val();
151+
152+ var dataOptions = {
153+ "sort": container.find("input[name=sort]").val(),
154+ "order": container.find("input[name=order]").val()
155+ };
156+
157+ // create the chart object (a backbone Collection)
158+ var tweets = new Rows;
159+ tweets.dataOptions = dataOptions;
160+ tweets.url = sf.plugins.twitter.url(id);
161+ tweets.sync = function(method, model, options){
162+ options.timeout = 10000;
163+ options.dataType = "jsonp";
164+ return Backbone.sync(method, model, options);
165+ };
166+ // update the chart (and set a refresh interval)
167+ tweets.update(container);
168+ setInterval(function(){
169+ tweets.update(container);
170+ }, 30000); // refresh interval
171+
172+ });
173+
174+ </script>
175+
176+ </body>
177+ </html>
0 commit comments