This repository was archived by the owner on May 8, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
122 lines (115 loc) · 3.67 KB
/
Copy pathapp.js
File metadata and controls
122 lines (115 loc) · 3.67 KB
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
var Netflix = require('netflix');
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var loading = Ti.UI.createView({
top: 0, right: 0, bottom: 0, left: 0,
backgroundColor: '#fff',
zIndex: 10,
opacity: 0.8
});
var loadingImage = Ti.UI.createImageView({
images: [
'loading/00.png', 'loading/01.png',
'loading/02.png', 'loading/03.png',
'loading/04.png', 'loading/05.png',
'loading/06.png', 'loading/07.png',
'loading/08.png', 'loading/09.png',
'loading/10.png', 'loading/11.png'
],
width: 33, height: 33
});
loadingImage.start();
loading.add(loadingImage);
win.add(loading);
var table = Ti.UI.createTableView();
table.addEventListener('click', function (evt) {
if (evt.row.id) {
loadOneMovie(evt.row.id);
}
else if (evt.row.action) {
skip += (evt.row.action == 'next' ? 1 : -1) * top;
loadListOfMovies(evt.row.action);
}
});
win.add(table);
win.addEventListener('open', loadListOfMovies);
win.open();
function errorHandler(message) {
loading.hide();
alert(message);
}
var top = 20, skip = 0;
function loadListOfMovies(action) {
Netflix.Title.find({
$filter: 'Type eq \'Movie\' and (Rating eq \'G\' or Rating eq \'PG-13\')',
$orderby: 'Name',
$top: top,
$skip: skip,
success: function (movies) {
var rows = [];
if (skip > 0) {
rows.push(Ti.UI.createTableViewRow({
title: 'Previous Page',
action: 'previous'
}));
}
for (var i = 0, l = movies.length; i < l; i++) {
var movie = movies[i];
var row = Ti.UI.createTableViewRow({
height: 60,
id: movie.Id,
hasChild: true
});
row.add(Ti.UI.createImageView({
image: movie.BoxArt.LargeUrl,
backgroundColor: '#000',
width: 70, height: 50, hires: true,
borderRadius: 5,
left: 5, top: 5,
targetDetailsView: 'photos'
}));
row.add(Ti.UI.createLabel({
text: movie.ShortName || movie.Name, textAlign: 'left',
font: { fontWeight: 'bold', fontSize: 12 },
wordWrap: false, ellipsize: true,
top: 7, left: 85, right: 0,
height: 14,
color: '#000'
}));
row.add(Ti.UI.createLabel({
text: movie.ShortSynopsis || movie.Synopsis, textAlign: 'left',
font: { fontSize: 10 },
wordWrap: true, ellipsize: true,
left: 85, right: 5, top: 20,
height: 32,
color: '#777'
}));
rows.push(row);
}
if (movies.length == top) {
rows.push(Ti.UI.createTableViewRow({
title: 'Next Page',
action: 'next'
}));
}
table.setData(rows, { animated: false });
if (action != undefined && typeof action == 'string') {
table.scrollToIndex(action == 'next' ? 0 : rows.length - 1, { animated: false });
}
loading.hide();
},
error: errorHandler
});
}
function loadOneMovie(id) {
loading.show();
Netflix.Title.findOne({
id: id,
success: function (movie) {
alert(movie.Synopsis);
loading.hide();
},
error: errorHandler
})
}