mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
moved everything up a directory
This commit is contained in:
parent
448cd8d92e
commit
9a78f790a6
76 changed files with 0 additions and 0 deletions
89
RequestPlex.UI/Content/search.js
Normal file
89
RequestPlex.UI/Content/search.js
Normal file
|
@ -0,0 +1,89 @@
|
|||
var searchSource = $("#search-template").html();
|
||||
var searchTemplate = Handlebars.compile(searchSource);
|
||||
var movieTimer = 0;
|
||||
var tvimer = 0;
|
||||
|
||||
$("#movieSearchContent").on("keyup", function (e) {
|
||||
if (movieTimer) {
|
||||
clearTimeout(movieTimer);
|
||||
}
|
||||
movieTimer = setTimeout(movieSearch, 400);
|
||||
});
|
||||
|
||||
$("#tvSearchContent").on("keyup", function (e) {
|
||||
if (tvimer) {
|
||||
clearTimeout(tvimer);
|
||||
}
|
||||
tvimer = setTimeout(tvSearch(), 400);
|
||||
});
|
||||
|
||||
function movieSearch() {
|
||||
$("#movieList").html("");
|
||||
var query = $("#movieSearchContent").val();
|
||||
|
||||
$.ajax("/search/movie/" + query).success(function (results) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildMovieContext(result);
|
||||
|
||||
var html = searchTemplate(context);
|
||||
$("#movieList").append(html);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function tvSearch() {
|
||||
$("#tvList").html("");
|
||||
var query = $("#tvSearchContent").val();
|
||||
|
||||
$.ajax("/search/tv/" + query).success(function (results) {
|
||||
results.forEach(function (result) {
|
||||
var context = buildTvShowContext(result);
|
||||
var html = searchTemplate(context);
|
||||
$("#tvList").append(html);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function buildMovieContext(result) {
|
||||
var date = new Date(result.releaseDate);
|
||||
var year = date.getFullYear();
|
||||
var context = {
|
||||
posterPath: result.posterPath,
|
||||
id: result.id,
|
||||
title: result.title,
|
||||
overview: result.overview,
|
||||
voteCount: result.voteCount,
|
||||
voteAverage: result.voteAverage,
|
||||
year: year,
|
||||
type : "movie"
|
||||
};
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
function buildTvShowContext(result) {
|
||||
var date = new Date(result.firstAirDate);
|
||||
var year = date.getFullYear();
|
||||
var context = {
|
||||
posterPath: result.posterPath,
|
||||
id: result.id,
|
||||
title: result.name,
|
||||
overview: result.overview,
|
||||
voteCount: result.voteCount,
|
||||
voteAverage: result.voteAverage,
|
||||
year: year,
|
||||
type: "tv"
|
||||
};
|
||||
return context;
|
||||
}
|
||||
|
||||
function generateNotify(message, type) {
|
||||
// type = danger, warning, info, successs
|
||||
$.notify({
|
||||
// options
|
||||
message: message
|
||||
}, {
|
||||
// settings
|
||||
type: type
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue