-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasic-json-call.html
330 lines (267 loc) · 10.5 KB
/
basic-json-call.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="viewport" content="width=device-width,user-scalable=no" />
<link rel="apple-touch-icon" href="http://www.itabbar.com/wp-content/themes/boldy/itabbar/img/logo72X72_flat.png"/>
<link rel="apple-touch-icon-precomposed" media="screen and (min-resolution: 326dpi)" href="http://www.itabbar.com/wp-content/themes/boldy/itabbar/img/logo72X72_flat.png" />
<link rel="apple-touch-icon-precomposed" href="http://www.itabbar.com/wp-content/themes/boldy/itabbar/img/logo72X72_flat.png"/>
<title> iTabbar Demo</title>
<style type="text/css">
.profilepic {
padding-right: 6px;
-webkit-border-radius: 5px;
border-radius:5px:
}
</style>
<!--<link rel="stylesheet" href="http://scripts.toolurl.com/mobile/1-tabbbar/themes/css/jqtouch.css"/> -->
<link rel="stylesheet" href="src/apple.css"/>
<link rel="stylesheet" href="src/itabbar.css"/><!--CSS order are important -->
<link rel="stylesheet" href="src/style.css"/>
<script type="text/javascript" src="src/iscroll.js"></script>
<script type='text/javascript' src='src/zepto.min.js'></script>
<script type='text/javascript' src='src/jqtouch.min.js'></script>
<script type='text/javascript' src='src/jqt.autotitles.min.js'></script>
<script type='text/javascript' src='src/twitter.js'></script>
<script type="text/javascript">
//use jQtouch fastouch work better for iPhone familly
function isiPhone(){
if(navigator.userAgent.match(/(iPhone|iPod|iPad|)/i)){
//alert('is iPhone');
return true;
}else{
return false;
}
}
var myScroll;
function loaded() {
setTimeout(function () {
myScroll = new iScroll('wrapper');
}, 1000);
}
//window.addEventListener('load', loaded, false);
/* Use this for high compatibility (iDevice + Android)*/
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', setTimeout(function () { loaded(); }, 200), false);
</script>
<script type="text/javascript" charset="utf-8">
var jQT = new $.jQTouch({
//cacheGetRequests: false,
icon: 'img/iTab-glossy.png',
icon4: 'img/iTab-glossy.png',
addGlossToIcon: false,
startupScreen: 'img/istartup.png',
statusBar: 'black-translucent',
themeSelectionSelector: '#jqt #themes ul',
useFastTouch: isiPhone(),
statusBar: 'default',
preloadImages: [
'img/loading.gif',
'img/iTab-glossy.png',
'img/pinstripes2.gif',
'img/UIBack.png',
'img/UIBackPressed.png',
]
});
var mydata = '';
// Main functions:
$(function() {
$('#twitterlist').bind('pageAnimationEnd', function(e, info) {
if (info.direction == 'in'){
var mydata = '';
$("#tweetappend").empty(); // Clear old result for new result
$("#tweet .toolbar H1").empty(); // Empty H1 header for autotitle
if (myScroll) {
myScroll.destroy();
myScroll = null;
//alert('destroy iscroll')
}
if ($('div#' + e.target.id + ' #wrapper').get(0)) {
setTimeout(function() {
myScroll = new iScroll($('div#' + e.target.id + ' #wrapper').get(0));
//alert('New iscroll');
}, 0);
}
}
}); //pageAnimationEnd
// Tweet
$('#tweet').bind('pageAnimationEnd', function(e, info) {
if (info.direction == 'in') {
showLoading();
$.getJSON('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=' + mydata + '&count=10&callback=?', function(data) {
if (myScroll) {
myScroll.destroy();
myScroll = null;
//alert('destroy iscroll')
}
if ($('div#' + e.target.id + ' #wrapper').get(0)) {
setTimeout(function() {
myScroll = new iScroll($('div#' + e.target.id + ' #wrapper').get(0));
//alert('New iscroll');
}, 0);
}
content = '<ul class="rounded">';
$.each(data, function(i) {
var tweet = ify.clean(this['text']);
var d = new Date(this['created_at']);
var date_show = d.getDate() + '/' + d.getMonth() + '/' + d.getFullYear() + ' ' + d.getHours() + ':' + d.getMinutes();
content += '<li><img src="' + this.user.profile_image_url + '" style="float:left;" width="48" height="48"/><p>' + tweet + '</p> (<date>' + date_show + '</date>)</li>';
}); //each
content += '</ul>';
$('#tweetappend').html(content);
//alert ('data empty');
hideLoading();
}); // getjson
} //direction in end
}); //pageAnimationEnd
// Twitter search
$('#tweetsearch').bind('pageAnimationEnd', function(e, info) {
if (info.direction == 'in') {
showLoading();
$.getJSON('http://search.twitter.com/search.json?callback=?&rpp=20&q=' + mydata + '', function(data) {
//Destroy and rebuild iSroll everytime you load something ajax
if (myScroll) {
myScroll.destroy();
myScroll = null;
}
if ($('div#' + e.target.id + ' #wrapper').get(0)) {
setTimeout(function() {
myScroll = new iScroll($('div#' + e.target.id + ' #wrapper').get(0));
}, 0);
}
content = '<ul class="rounded">';
$.each(data.results, function(i, item) {
// $.each(data, function(i) {
content += '<li><img class="profilepic" src="' + item.profile_image_url + '" style="float:left;" width="48" height="48"/><p>' + item.text + '</p></li>';
}); //each
content += '</ul>';
$('#twsearchresult').append(content);
hideLoading();
}); // getjson
} //direction in end
}); //pageAnimationEnd
// search page // We add it to clear old result in the content and H1 toolbar
$('#search').bind('pageAnimationEnd', function(e, info) {
if (info.direction == 'in'){
var s = ''; // clear last search result
$("#twsearchresult").empty();
$("#tweetsearch .toolbar H1").empty(); // Empty H1 header for autotitle
}
}); //pageAnimationEnd
}); //end all function()
</script>
</head>
<body>
<div id="jqt">
<!-- #home-->
<!-- End #home -->
<!-- #twitterlist -->
<div id="twitterlist" class="current">
<div class="toolbar">
<h1>Twitter users list</h1>
</div>
<div id="wrapper">
<div id="scroller">
<ul class="edgetoedge">
<li class="list arrow"><a onClick="send('itabbar')" id="" href="#tweet" class="">@iTabbar</a></li>
<li class="list arrow"><a onClick="send('jqtouch')" id="" href="#tweet" class="">@jQtouch</a></li>
<li class="list arrow"><a onClick="send('iScroll')" id="" href="#tweet" class="">@iScroll</a></li>
<li class="list arrow"><a onClick="send('techcrunch')" id="" href="#tweet" class="">@Techcrunch</a></li>
<li class="list arrow"><a onClick="send('appsmobiledev')" id="" href="#tweet" class="">@appsmobiledev</a></li>
<li class="list arrow"><a onClick="send('ginocote')" id="" href="#tweet" class="">@Gino</a></li>
<li class="list arrow"><a onClick="send('pascalcarmoni')" id="" href="#tweet" class="">@pascalcarmoni</a></li>
<li class="list arrow"><a onClick="send('templateswise')" id="" href="#tweet" class="">@templateswise</a></li>
<li class="list arrow"><a onClick="send('FousduRoi')" id="" href="#tweet" class="">Les Fous du Roi</a></li>
</ul>
</div>
</div>
</div>
<!-- End #twitterlist -->
<!-- #tweet -->
<div id="tweet">
<div class="toolbar">
<h1>Techcrunch</h1>
<a class="back" href="#">Back</a></div>
<div id="wrapper">
<div id="scroller">
<div id="tweetappend"></div>
</div>
</div>
</div>
<!-- End #tweet -->
<!-- #tweet search result -->
<div id="tweetsearch">
<div class="toolbar">
<h1></h1>
<a class="back" href="#">Back</a></div>
<div id="wrapper">
<div id="scroller">
<div id="twsearchresult"></div>
</div>
</div>
</div>
<!-- End #tweet search result -->
<!-- #search -->
<form id="search" class="form">
<div class="toolbar">
<h1>Search</h1>
<a class="cancel" href="#">Cancel</a>
</div>
<div class="scroll">
<ul class="rounded">
<li><input type="search" id="searchid" name="s" value="" placeholder="Search" /></li>
</ul>
<a style="margin-top: 10px; margin-bottom: 10px; color:rgba(0,0,0,.9)" href="#tweetsearch" id="submit" class="whiteButton">Search Twitter</a>
</div>
</form>
<!-- End #search -->
<!-- #about -->
<div id="about" class="selectable">
<p><img src="http://www.itabbar.com/wp-content/themes/boldy/itabbar/img/iTab-glossy.png" /></p>
<p><strong>iTabbar</strong><br>Version 0.1 beta<br>
<a href="http://www.itabbar.com">By Gino Côté</a></p>
<p><em>Create powerful mobile apps with<br> just iTabbar, HTML, CSS, and jQuery.</em></p>
<p>
<a target="_blank" href="http://twitter.com/itabbar">@iTabbar on Twitter</a> </p>
<p><br><br><a href="#" class="grayButton goback">Close</a></p>
</div>
<!-- End #about -->
</div> <!-- End #jqt -->
<nav id="tabbar">
<ul >
<!-- Action & navigation -->
<li><a href="#twitterlist" class="current flip"><strong>Home</strong><div class="home"></div></a></li>
<li><a href="#twitterlist" class="flip"><strong>Twitter</strong><div class="twitter"></div></a></li>
<li><a href="#search" class="flip"><strong>Search</strong><div class="search2"></div></a></li>
</ul>
</nav>
<div id="loading"><p><img src="img/loading.gif" /></p></div>
<script type="text/javascript">
//Send ID and Search onclick
function send(d) {
mydata = d;
//$("#rssfeed .toolbar H1").empty();
}
$("#submit").tap(function(e) { // onclick event to the submit button - .tap or .click.
var s = $("#searchid").val(); // get the user-entered search term
$("#tweetsearch .toolbar H1").append(s);// Add search query to Toolbar
send(s)
//alert(s);
});
//ajax loading animation
function showLoading() {
//$("div.container").show();
$("#loading").show(); // If image gif
}
function hideLoading() {
//$("div.container").hide();
$("#loading").hide(); // If image gif
}
</script>
<script type='text/javascript' src='src/itabbar.js'></script>
<script type='text/javascript' src='src/fullscreen.js'></script>
</body>
</html>