forked from purplecabbage/GloveBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
315 lines (254 loc) · 7.31 KB
/
index.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html>
<head>
<!-- Change this if you want to allow scaling -->
<meta name="viewport" content="width=devicewidth; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>GloveBox Demo - trends on twitter</title>
<link media="screen" href="style.css" type= "text/css" rel="stylesheet" />
<script src="GloveBox.js" type="text/javascript" charset="utf-8"></script>
<style>
#spScale
{
color:#FFF;
position:absolute;
left:20px;
top:40px;
background-color:rgba(0,0,0,0.5);
}
#spX
{
color:#FFF;
position:absolute;
left:20px;
top:60px;
background-color:rgba(0,0,0,0.5);
}
#spY
{
color:#FFF;
position:absolute;
left:20px;
top:80px;
background-color:rgba(0,0,0,0.5);
}
#spWidth
{
color:#FFF;
position:absolute;
left:20px;
top:100px;
background-color:rgba(0,0,0,0.5);
}
dl
{
color:#fff;
}
dt
{
background-color:#666;
font-weight:bold;
text-indent:10px;
margin:0px 2px;
padding:10px 20px;
}
dd
{
text-indent:12px;
line-height:24px;
margin:4px 4px;
padding:5px 5px;
text-overflow:ellipsis;
overflow:hidden;
border:1px dotted #555;
-webkit-border-radius: 8px;
}
img {
border: 0;
}
#tweetList {
color: #ddd;
}
#tweetList .tweet {
padding: 8px;
background:rgba(64,64,64,0.5);
border: 1px solid rgba(128,128,128,0.5);
opacity: 0.8;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
margin-bottom: .5em;
}
#tweetList a {
color: #05635F;
text-decoration: underline;
}
#tweetList .avatar {
float: left;
}
#tweetList .content
{
border:none;
padding-left: 55px;
}
#tweetList .extra {
color: #999;
}
#tweetList h4
{
width:100%;
text-align:center;
margin:40px 40px;
}
*
{
/* prevent callout to copy image, etc when tap to hold */
-webkit-touch-callout: none;
/* prevent webkit from resizing text to fit */
-webkit-text-size-adjust: none;
/* make transparent link selection, adjust last value opacity 0 to 1.0 */
-webkit-tap-highlight-color: rgba(0,0,0,0);
/* prevent copy paste, to allow, change 'none' to 'text' */
-webkit-user-select: none;
}
</style>
<script type="text/javascript" charset="utf-8">
// http://api.twitter.com/1/trends/weekly.json
var trendUrl = "http://api.twitter.com/1/trends/weekly.json?exclude=hashtags&callback=onGotTrending";
var searchUrl = "http://search.twitter.com/search.json?callback=onGotDetails&q=";
var searchScript; // so we can remove it, before reusing it
var tweetScroller;
var trendScroller;
var targetElement; // selected item in the list
function onBodyLoad()
{
document.addEventListener("touchmove", preventBehavior, false);
var btnScroll = new GloveBox(document.getElementById("horzList"));
btnScroll.scrollX = true;
btnScroll.scrollY = false;
window.scrollTo(0, -200);
trendScroller = new GloveBox(document.getElementById("masterList"));
tweetScroller = new GloveBox(document.getElementById("tweetList"));
getTrending();
}
function getTrending()
{
var head = document.getElementsByTagName('head');
var script = document.createElement('script');
script.src = trendUrl;
head[0].appendChild(script);
}
function onGotTrending(res)
{
var list = "";
var fTrend;
for (var dt in res.trends) {
list += "<dt>" + dt + "</dt>";
var items = res.trends[dt];
for (var item in items) {
if (fTrend == null)
fTrend = items[item].name;
list += "<dd onclick=\"getDetail(event,'" + items[item].query + "')\">" + items[item].name + "</dd>";
}
}
document.getElementById("masterList").innerHTML = list;
// now grab the first one
getDetail(null,fTrend);
}
function getDetail(event,str)
{
if (event != null) {
if (targetElement != null) {
targetElement.style.backgroundColor = "#222";
}
targetElement = event.target;
targetElement.style.backgroundColor = "#05635F";
}
var head = document.getElementsByTagName('head');
if (searchScript == null) {
searchScript = document.createElement('script');
searchScript.src = searchUrl + str;
head[0].appendChild(searchScript);
}
else {
head[0].removeChild(searchScript);
searchScript = document.createElement('script');
searchScript.src = searchUrl + str;
head[0].appendChild(searchScript);
}
document.getElementById('tweetList').innerHTML = "<h4>" + str + " Loading ... </h4>";
tweetScroller.y = 0;
return false;
}
function onGotDetails(json)
{
var q;
var parent = document.getElementById('tweetList');
parent.innerHTML = '';
var child;
var html = "";
for (var i in json.results)
{
q = json.results[i];
html += "<div class='tweet'>";
html += '<div class="avatar"><img src="' + q.profile_image_url + '" alt="avatar" width="48" height="48" /></div>';
var date = new Date(q.created_at);
html += '<div class="content"><a href="http://m.twitter.com/' + q.from_user + '">' + q.from_user + '</a> ' + q.text + '<div class="extra">' + date.toLocaleDateString() + '</div></div>';
html += "</div>";
}
parent.innerHTML = html;
}
function preventBehavior(e)
{
e.preventDefault();
};
</script>
</head>
<body onload="onBodyLoad()">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9634898-1']);
_gaq.push(['_trackPageview']);
(function()
{
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div id="header">
<h1>Trends on Twitter</h1>
</div>
<div style="width:100%;position:absolute;bottom:49px;top:44px;overflow:hidden;">
<div id="master" style="width:260px;height:100%;overflow:hidden;float:left;clear:none;">
<dl id="masterList">
</dl>
</div>
<div id="tweetBox" style="height:100%;overflow:hidden;margin-left:20px;">
<div id="tweetList" >
</div>
</div>
</div>
<span id="spScale"></span>
<span id="spX"></span>
<span id="spY"></span>
<span id="spWidth"></span>
<!--
</div>
</div>
-->
<div id="footer">
<ul id="horzList">
<li class="team"><span>Team</span></li>
<li class="feed"><span>Feed</span></li>
<li class="post"><span>Post</span></li>
<li class="box"><span>Box</span></li>
<li class="games"><span>Games</span></li>
<li class="team"><span>Team</span></li>
<li class="feed"><span>Feed</span></li>
<li class="post"><span>Post</span></li>
<li class="box"><span>Box</span></li>
<li class="games"><span>Games</span></li>
</ul>
</div>
</body>
</html>