-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.js
50 lines (47 loc) · 1.38 KB
/
page.js
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
$(document).ready(function(){
/**************
CREATE FILTER
**************/
window.disc = new Discoverer();
disc.addFilter("person","=","kevin spacey")
disc.addFilter("date","<","2013");
disc.addFilter("date",">","2000");
disc.addSort("popularity","desc");
disc.discover(addMovies);
});
/************
Add Movies To Display;
*************/
function addMovies(data){
var config = data.config;
var results = data.results;
var totalMovies = results.length;
var cont = $("body");
//cont.html("");
var offset = 0;
var i=0;
while(i<totalMovies && i < results.length && offset < results.length){
var movie = results[offset];
if(movie && movie.poster_path){
var title=undefined;
if(!movie.poster_path)title = movie.title;
movie.poster_path = (movie.poster_path?config.images.base_url+config.images.poster_sizes[config.images.poster_sizes.length-1]+movie.poster_path:"http://www.directv.com/img/movies.jpg");
var anc = $("<a/>");
anc.attr("href","https://www.themoviedb.org/movie/"+ movie.id);
anc.addClass("poster");
var poster = $("<img/>");
poster.class="poster";
poster.attr("src",movie.poster_path);
poster.addClass("island");
anc.append(poster);
if(title)anc.append("<p class='movie_title'>"+title+"</p>");
cont.append(anc);
i++;
}
offset++;
}
if(data.total_pages>disc.page){
disc.page = disc.page+1;
disc.discover(addMovies);
}
}