mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Work on the requests page mostly done.
This commit is contained in:
parent
70362b908f
commit
98d143c9b2
17 changed files with 297 additions and 78 deletions
71
RequestPlex.UI/Content/requests.js
Normal file
71
RequestPlex.UI/Content/requests.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
Handlebars.registerHelper('if_eq', function (a, b, opts) {
|
||||
if (a == b)
|
||||
return opts.fn(this);
|
||||
else
|
||||
return opts.inverse(this);
|
||||
});
|
||||
|
||||
var searchSource = $("#search-template").html();
|
||||
var searchTemplate = Handlebars.compile(searchSource);
|
||||
var movieTimer = 0;
|
||||
var tvimer = 0;
|
||||
|
||||
movieLoad();
|
||||
tvLoad();
|
||||
|
||||
|
||||
function movieLoad() {
|
||||
$("#movieList").html("");
|
||||
|
||||
$.ajax("/requests/movies/").success(function (results) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildMovieRequestContext(result);
|
||||
|
||||
var html = searchTemplate(context);
|
||||
$("#movieList").append(html);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function tvLoad() {
|
||||
$("#tvList").html("");
|
||||
|
||||
$.ajax("/requests/tvshows/").success(function (results) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildTvShowRequestContext(result);
|
||||
var html = searchTemplate(context);
|
||||
$("#tvList").append(html);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function buildMovieRequestContext(result) {
|
||||
var date = new Date(result.releaseDate);
|
||||
var year = date.getFullYear();
|
||||
var context = {
|
||||
posterPath: result.posterPath,
|
||||
id: result.tmdbid,
|
||||
title: result.title,
|
||||
overview: result.overview,
|
||||
year: year,
|
||||
type: "movie"
|
||||
};
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
function buildTvShowRequestContext(result) {
|
||||
var date = new Date(result.releaseDate);
|
||||
var year = date.getFullYear();
|
||||
var context = {
|
||||
posterPath: result.posterPath,
|
||||
id: result.tmdbid,
|
||||
title: result.name,
|
||||
overview: result.overview,
|
||||
voteCount: result.voteCount,
|
||||
voteAverage: result.voteAverage,
|
||||
year: year,
|
||||
type: "tv"
|
||||
};
|
||||
return context;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue