mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
finished #26
This commit is contained in:
parent
2187b1453a
commit
b2144f3f69
7 changed files with 1122 additions and 1100 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,453 +1,462 @@
|
||||||
Handlebars.registerHelper('if_eq', function (a, b, opts) {
|
Handlebars.registerHelper('if_eq', function (a, b, opts) {
|
||||||
if (a == b)
|
if (a == b)
|
||||||
return opts.fn(this);
|
return opts.fn(this);
|
||||||
else
|
else
|
||||||
return opts.inverse(this);
|
return opts.inverse(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
var searchSource = $("#search-template").html();
|
var searchSource = $("#search-template").html();
|
||||||
var seasonsSource = $("#seasons-template").html();
|
var seasonsSource = $("#seasons-template").html();
|
||||||
var musicSource = $("#music-template").html();
|
var musicSource = $("#music-template").html();
|
||||||
var searchTemplate = Handlebars.compile(searchSource);
|
var searchTemplate = Handlebars.compile(searchSource);
|
||||||
var musicTemplate = Handlebars.compile(musicSource);
|
var musicTemplate = Handlebars.compile(musicSource);
|
||||||
var seasonsTemplate = Handlebars.compile(seasonsSource);
|
var seasonsTemplate = Handlebars.compile(seasonsSource);
|
||||||
|
|
||||||
var base = $('#baseUrl').text();
|
var base = $('#baseUrl').text();
|
||||||
|
|
||||||
var searchTimer = 0;
|
var searchTimer = 0;
|
||||||
|
|
||||||
// fix for selecting a default tab
|
// fix for selecting a default tab
|
||||||
var $tabs = $('#nav-tabs').children('li');
|
var $tabs = $('#nav-tabs').children('li');
|
||||||
if ($tabs.filter(function (li) { return $(li).hasClass('active') }).length <= 0) {
|
if ($tabs.filter(function (li) { return $(li).hasClass('active') }).length <= 0) {
|
||||||
$tabs.first().children('a:first-child').tab('show');
|
$tabs.first().children('a:first-child').tab('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
focusSearch($($(e.target).attr('href')));
|
focusSearch($($(e.target).attr('href')));
|
||||||
});
|
});
|
||||||
focusSearch($('li.active a', '#nav-tabs').first().attr('href'));
|
focusSearch($('li.active a', '#nav-tabs').first().attr('href'));
|
||||||
|
|
||||||
// Get the user notification setting
|
// Get the user notification setting
|
||||||
var url = createBaseUrl(base, '/search/notifyuser/');
|
var url = createBaseUrl(base, '/search/notifyuser/');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "get",
|
type: "get",
|
||||||
url: url,
|
url: url,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
$('#notifyUser').prop("checked", response);
|
$('#notifyUser').prop("checked", response);
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Type in movie search
|
// Type in movie search
|
||||||
$("#movieSearchContent").on("input", function () {
|
$("#movieSearchContent").on("input", function () {
|
||||||
if (searchTimer) {
|
if (searchTimer) {
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
}
|
}
|
||||||
searchTimer = setTimeout(movieSearch, 400);
|
searchTimer = setTimeout(movieSearch, 400);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#moviesComingSoon').on('click', function (e) {
|
$('#moviesComingSoon').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
moviesComingSoon();
|
moviesComingSoon();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#moviesInTheaters').on('click', function (e) {
|
$('#moviesInTheaters').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
moviesInTheaters();
|
moviesInTheaters();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Type in TV search
|
// Type in TV search
|
||||||
$("#tvSearchContent").on("input", function () {
|
$("#tvSearchContent").on("input", function () {
|
||||||
if (searchTimer) {
|
if (searchTimer) {
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
}
|
}
|
||||||
searchTimer = setTimeout(tvSearch, 400);
|
searchTimer = setTimeout(tvSearch, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Click TV dropdown option
|
// Click TV dropdown option
|
||||||
$(document).on("click", ".dropdownTv", function (e) {
|
$(document).on("click", ".dropdownTv", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var buttonId = e.target.id;
|
var buttonId = e.target.id;
|
||||||
if ($("#" + buttonId).attr('disabled')) {
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#" + buttonId).prop("disabled", true);
|
$("#" + buttonId).prop("disabled", true);
|
||||||
loadingButton(buttonId, "primary");
|
loadingButton(buttonId, "primary");
|
||||||
|
|
||||||
|
|
||||||
var $form = $('#form' + buttonId);
|
var $form = $('#form' + buttonId);
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
var seasons = $(this).attr("season-select");
|
var seasons = $(this).attr("season-select");
|
||||||
if (seasons === "2") {
|
if (seasons === "2") {
|
||||||
// Send over the latest
|
// Send over the latest
|
||||||
data = data + "&seasons=latest";
|
data = data + "&seasons=latest";
|
||||||
}
|
}
|
||||||
if (seasons === "1") {
|
if (seasons === "1") {
|
||||||
// Send over the first season
|
// Send over the first season
|
||||||
data = data + "&seasons=first";
|
data = data + "&seasons=first";
|
||||||
}
|
} if (seasons === "0") {
|
||||||
|
// Send over the first season
|
||||||
var type = $form.prop('method');
|
data = data + "&seasons=all";
|
||||||
var url = $form.prop('action');
|
}
|
||||||
|
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
var type = $form.prop('method');
|
||||||
});
|
var url = $form.prop('action');
|
||||||
|
|
||||||
// Search Music
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
$("#musicSearchContent").on("input", function () {
|
});
|
||||||
if (searchTimer) {
|
|
||||||
clearTimeout(searchTimer);
|
// Search Music
|
||||||
}
|
$("#musicSearchContent").on("input", function () {
|
||||||
searchTimer = setTimeout(musicSearch, 400);
|
if (searchTimer) {
|
||||||
|
clearTimeout(searchTimer);
|
||||||
});
|
}
|
||||||
|
searchTimer = setTimeout(musicSearch, 400);
|
||||||
// Click Request for movie
|
|
||||||
$(document).on("click", ".requestMovie", function (e) {
|
});
|
||||||
e.preventDefault();
|
|
||||||
var buttonId = e.target.id;
|
// Click Request for movie
|
||||||
if ($("#" + buttonId).attr('disabled')) {
|
$(document).on("click", ".requestMovie", function (e) {
|
||||||
return;
|
e.preventDefault();
|
||||||
}
|
var buttonId = e.target.id;
|
||||||
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
$("#" + buttonId).prop("disabled", true);
|
return;
|
||||||
loadingButton(buttonId, "primary");
|
}
|
||||||
|
|
||||||
|
$("#" + buttonId).prop("disabled", true);
|
||||||
var $form = $('#form' + buttonId);
|
loadingButton(buttonId, "primary");
|
||||||
|
|
||||||
var type = $form.prop('method');
|
|
||||||
var url = $form.prop('action');
|
var $form = $('#form' + buttonId);
|
||||||
var data = $form.serialize();
|
|
||||||
|
var type = $form.prop('method');
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
var url = $form.prop('action');
|
||||||
|
var data = $form.serialize();
|
||||||
});
|
|
||||||
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
// Click Request for album
|
|
||||||
$(document).on("click", ".requestAlbum", function (e) {
|
});
|
||||||
e.preventDefault();
|
|
||||||
var buttonId = e.target.id;
|
// Click Request for album
|
||||||
if ($("#" + buttonId).attr('disabled')) {
|
$(document).on("click", ".requestAlbum", function (e) {
|
||||||
return;
|
e.preventDefault();
|
||||||
}
|
var buttonId = e.target.id;
|
||||||
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
$("#" + buttonId).prop("disabled", true);
|
return;
|
||||||
loadingButton(buttonId, "primary");
|
}
|
||||||
|
|
||||||
|
$("#" + buttonId).prop("disabled", true);
|
||||||
var $form = $('#form' + buttonId);
|
loadingButton(buttonId, "primary");
|
||||||
|
|
||||||
var type = $form.prop('method');
|
|
||||||
var url = $form.prop('action');
|
var $form = $('#form' + buttonId);
|
||||||
var data = $form.serialize();
|
|
||||||
|
var type = $form.prop('method');
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
var url = $form.prop('action');
|
||||||
});
|
var data = $form.serialize();
|
||||||
|
|
||||||
// Enable/Disable user notifications
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
$('#saveNotificationSettings')
|
});
|
||||||
.click(function (e) {
|
|
||||||
e.preventDefault();
|
// Enable/Disable user notifications
|
||||||
var url = createBaseUrl(base, '/search/notifyuser/');
|
$('#saveNotificationSettings')
|
||||||
var checked = $('#notifyUser').prop('checked');
|
.click(function (e) {
|
||||||
$.ajax({
|
e.preventDefault();
|
||||||
type: "post",
|
var url = createBaseUrl(base, '/search/notifyuser/');
|
||||||
url: url,
|
var checked = $('#notifyUser').prop('checked');
|
||||||
data: { notify: checked },
|
$.ajax({
|
||||||
dataType: "json",
|
type: "post",
|
||||||
success: function (response) {
|
url: url,
|
||||||
console.log(response);
|
data: { notify: checked },
|
||||||
if (response.result === true) {
|
dataType: "json",
|
||||||
generateNotify(response.message || "Success!", "success");
|
success: function (response) {
|
||||||
} else {
|
console.log(response);
|
||||||
generateNotify(response.message, "warning");
|
if (response.result === true) {
|
||||||
}
|
generateNotify(response.message || "Success!", "success");
|
||||||
},
|
} else {
|
||||||
error: function (e) {
|
generateNotify(response.message, "warning");
|
||||||
console.log(e);
|
}
|
||||||
generateNotify("Something went wrong!", "danger");
|
},
|
||||||
}
|
error: function (e) {
|
||||||
});
|
console.log(e);
|
||||||
});
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
function focusSearch($content) {
|
});
|
||||||
if ($content.length > 0) {
|
});
|
||||||
$('input[type=text].form-control', $content).first().focus();
|
|
||||||
}
|
function focusSearch($content) {
|
||||||
}
|
if ($content.length > 0) {
|
||||||
|
$('input[type=text].form-control', $content).first().focus();
|
||||||
function sendRequestAjax(data, type, url, buttonId) {
|
}
|
||||||
$.ajax({
|
}
|
||||||
type: type,
|
|
||||||
url: url,
|
function sendRequestAjax(data, type, url, buttonId) {
|
||||||
data: data,
|
$.ajax({
|
||||||
dataType: "json",
|
type: type,
|
||||||
success: function (response) {
|
url: url,
|
||||||
console.log(response);
|
data: data,
|
||||||
if (response.result === true) {
|
dataType: "json",
|
||||||
generateNotify(response.message || "Success!", "success");
|
success: function (response) {
|
||||||
|
console.log(response);
|
||||||
$('#' + buttonId).html("<i class='fa fa-check'></i> Requested");
|
if (response.result === true) {
|
||||||
$('#' + buttonId).removeClass("btn-primary-outline");
|
generateNotify(response.message || "Success!", "success");
|
||||||
$('#' + buttonId).removeAttr("data-toggle");
|
|
||||||
$('#' + buttonId).addClass("btn-success-outline");
|
$('#' + buttonId).html("<i class='fa fa-check'></i> Requested");
|
||||||
} else {
|
$('#' + buttonId).removeClass("btn-primary-outline");
|
||||||
generateNotify(response.message, "warning");
|
$('#' + buttonId).removeAttr("data-toggle");
|
||||||
$('#' + buttonId).html("<i class='fa fa-plus'></i> Request");
|
$('#' + buttonId).addClass("btn-success-outline");
|
||||||
$('#' + buttonId).attr("data-toggle", "dropdown");
|
} else {
|
||||||
$("#" + buttonId).removeAttr("disabled");
|
generateNotify(response.message, "warning");
|
||||||
}
|
$('#' + buttonId).html("<i class='fa fa-plus'></i> Request");
|
||||||
},
|
$('#' + buttonId).attr("data-toggle", "dropdown");
|
||||||
error: function (e) {
|
$("#" + buttonId).removeAttr("disabled");
|
||||||
console.log(e);
|
}
|
||||||
generateNotify("Something went wrong!", "danger");
|
},
|
||||||
}
|
error: function (e) {
|
||||||
});
|
console.log(e);
|
||||||
}
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
function movieSearch() {
|
});
|
||||||
var query = $("#movieSearchContent").val();
|
}
|
||||||
var url = createBaseUrl(base, '/search/movie/');
|
|
||||||
query ? getMovies(url + query) : resetMovies();
|
function movieSearch() {
|
||||||
}
|
var query = $("#movieSearchContent").val();
|
||||||
|
var url = createBaseUrl(base, '/search/movie/');
|
||||||
function moviesComingSoon() {
|
query ? getMovies(url + query) : resetMovies();
|
||||||
var url = createBaseUrl(base, '/search/movie/upcoming');
|
}
|
||||||
getMovies(url);
|
|
||||||
}
|
function moviesComingSoon() {
|
||||||
|
var url = createBaseUrl(base, '/search/movie/upcoming');
|
||||||
function moviesInTheaters() {
|
getMovies(url);
|
||||||
var url = createBaseUrl(base, '/search/movie/playing');
|
}
|
||||||
getMovies(url);
|
|
||||||
}
|
function moviesInTheaters() {
|
||||||
|
var url = createBaseUrl(base, '/search/movie/playing');
|
||||||
function getMovies(url) {
|
getMovies(url);
|
||||||
resetMovies();
|
}
|
||||||
|
|
||||||
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
|
function getMovies(url) {
|
||||||
$.ajax(url).success(function (results) {
|
resetMovies();
|
||||||
if (results.length > 0) {
|
|
||||||
results.forEach(function (result) {
|
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||||
var context = buildMovieContext(result);
|
$.ajax(url).success(function (results) {
|
||||||
|
if (results.length > 0) {
|
||||||
var html = searchTemplate(context);
|
results.forEach(function (result) {
|
||||||
$("#movieList").append(html);
|
var context = buildMovieContext(result);
|
||||||
});
|
|
||||||
}
|
var html = searchTemplate(context);
|
||||||
else {
|
$("#movieList").append(html);
|
||||||
$("#movieList").html(noResultsHtml);
|
});
|
||||||
}
|
}
|
||||||
$('#movieSearchButton').attr("class", "fa fa-search");
|
else {
|
||||||
});
|
$("#movieList").html(noResultsHtml);
|
||||||
};
|
}
|
||||||
|
$('#movieSearchButton').attr("class", "fa fa-search");
|
||||||
function resetMovies() {
|
});
|
||||||
$("#movieList").html("");
|
};
|
||||||
}
|
|
||||||
|
function resetMovies() {
|
||||||
function tvSearch() {
|
$("#movieList").html("");
|
||||||
var query = $("#tvSearchContent").val();
|
}
|
||||||
|
|
||||||
var url = createBaseUrl(base, '/search/tv/');
|
function tvSearch() {
|
||||||
query ? getTvShows(url + query) : resetTvShows();
|
var query = $("#tvSearchContent").val();
|
||||||
}
|
|
||||||
|
var url = createBaseUrl(base, '/search/tv/');
|
||||||
function getTvShows(url) {
|
query ? getTvShows(url + query) : resetTvShows();
|
||||||
resetTvShows();
|
}
|
||||||
|
|
||||||
$('#tvSearchButton').attr("class", "fa fa-spinner fa-spin");
|
function getTvShows(url) {
|
||||||
$.ajax(url).success(function (results) {
|
resetTvShows();
|
||||||
if (results.length > 0) {
|
|
||||||
results.forEach(function (result) {
|
$('#tvSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||||
var context = buildTvShowContext(result);
|
$.ajax(url).success(function (results) {
|
||||||
var html = searchTemplate(context);
|
if (results.length > 0) {
|
||||||
$("#tvList").append(html);
|
results.forEach(function (result) {
|
||||||
});
|
var context = buildTvShowContext(result);
|
||||||
}
|
var html = searchTemplate(context);
|
||||||
else {
|
$("#tvList").append(html);
|
||||||
$("#tvList").html(noResultsHtml);
|
});
|
||||||
}
|
}
|
||||||
$('#tvSearchButton').attr("class", "fa fa-search");
|
else {
|
||||||
});
|
$("#tvList").html(noResultsHtml);
|
||||||
};
|
}
|
||||||
|
$('#tvSearchButton').attr("class", "fa fa-search");
|
||||||
function resetTvShows() {
|
});
|
||||||
$("#tvList").html("");
|
};
|
||||||
}
|
|
||||||
|
function resetTvShows() {
|
||||||
function musicSearch() {
|
$("#tvList").html("");
|
||||||
var url = createBaseUrl(base, '/search/music/');
|
}
|
||||||
var query = $("#musicSearchContent").val();
|
|
||||||
query ? getMusic(url + query) : resetMusic();
|
function musicSearch() {
|
||||||
}
|
var url = createBaseUrl(base, '/search/music/');
|
||||||
|
var query = $("#musicSearchContent").val();
|
||||||
function getMusic(url) {
|
query ? getMusic(url + query) : resetMusic();
|
||||||
resetMusic();
|
}
|
||||||
|
|
||||||
$('#musicSearchButton').attr("class", "fa fa-spinner fa-spin");
|
function getMusic(url) {
|
||||||
$.ajax(url).success(function (results) {
|
resetMusic();
|
||||||
if (results.length > 0) {
|
|
||||||
results.forEach(function (result) {
|
$('#musicSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||||
var context = buildMusicContext(result);
|
$.ajax(url).success(function (results) {
|
||||||
|
if (results.length > 0) {
|
||||||
var html = musicTemplate(context);
|
results.forEach(function (result) {
|
||||||
$("#musicList").append(html);
|
var context = buildMusicContext(result);
|
||||||
getCoverArt(context.id);
|
|
||||||
});
|
var html = musicTemplate(context);
|
||||||
}
|
$("#musicList").append(html);
|
||||||
else {
|
getCoverArt(context.id);
|
||||||
$("#musicList").html(noResultsMusic);
|
});
|
||||||
}
|
}
|
||||||
$('#musicSearchButton').attr("class", "fa fa-search");
|
else {
|
||||||
});
|
$("#musicList").html(noResultsMusic);
|
||||||
};
|
}
|
||||||
|
$('#musicSearchButton').attr("class", "fa fa-search");
|
||||||
function resetMusic() {
|
});
|
||||||
$("#musicList").html("");
|
};
|
||||||
}
|
|
||||||
|
function resetMusic() {
|
||||||
function getCoverArt(artistId) {
|
$("#musicList").html("");
|
||||||
|
}
|
||||||
var url = createBaseUrl(base, '/search/music/coverart/');
|
|
||||||
$.ajax(url + artistId).success(function (result) {
|
function getCoverArt(artistId) {
|
||||||
if (result) {
|
|
||||||
$('#' + artistId + "imageDiv").html(" <img class='img-responsive' src='" + result + "' width='150' alt='poster'>");
|
var url = createBaseUrl(base, '/search/music/coverart/');
|
||||||
}
|
$.ajax(url + artistId).success(function (result) {
|
||||||
});
|
if (result) {
|
||||||
};
|
$('#' + artistId + "imageDiv").html(" <img class='img-responsive' src='" + result + "' width='150' alt='poster'>");
|
||||||
|
}
|
||||||
function buildMovieContext(result) {
|
});
|
||||||
var date = new Date(result.releaseDate);
|
};
|
||||||
var year = date.getFullYear();
|
|
||||||
var context = {
|
function buildMovieContext(result) {
|
||||||
posterPath: result.posterPath,
|
var date = new Date(result.releaseDate);
|
||||||
id: result.id,
|
var year = date.getFullYear();
|
||||||
title: result.title,
|
var context = {
|
||||||
overview: result.overview,
|
posterPath: result.posterPath,
|
||||||
voteCount: result.voteCount,
|
id: result.id,
|
||||||
voteAverage: result.voteAverage,
|
title: result.title,
|
||||||
year: year,
|
overview: result.overview,
|
||||||
type: "movie",
|
voteCount: result.voteCount,
|
||||||
imdb: result.imdbId,
|
voteAverage: result.voteAverage,
|
||||||
requested: result.requested,
|
year: year,
|
||||||
approved: result.approved,
|
type: "movie",
|
||||||
available: result.available
|
imdb: result.imdbId,
|
||||||
};
|
requested: result.requested,
|
||||||
|
approved: result.approved,
|
||||||
return context;
|
available: result.available
|
||||||
}
|
};
|
||||||
|
|
||||||
function buildTvShowContext(result) {
|
return context;
|
||||||
var date = new Date(result.firstAired);
|
}
|
||||||
var year = date.getFullYear();
|
|
||||||
var context = {
|
function buildTvShowContext(result) {
|
||||||
posterPath: result.banner,
|
var date = new Date(result.firstAired);
|
||||||
id: result.id,
|
var year = date.getFullYear();
|
||||||
title: result.seriesName,
|
var context = {
|
||||||
overview: result.overview,
|
posterPath: result.banner,
|
||||||
year: year,
|
id: result.id,
|
||||||
type: "tv",
|
title: result.seriesName,
|
||||||
imdb: result.imdbId,
|
overview: result.overview,
|
||||||
requested: result.requested,
|
year: year,
|
||||||
approved: result.approved,
|
type: "tv",
|
||||||
available: result.available
|
imdb: result.imdbId,
|
||||||
};
|
requested: result.requested,
|
||||||
return context;
|
approved: result.approved,
|
||||||
}
|
available: result.available
|
||||||
|
};
|
||||||
function buildMusicContext(result) {
|
return context;
|
||||||
|
}
|
||||||
var context = {
|
|
||||||
id: result.id,
|
function buildMusicContext(result) {
|
||||||
title: result.title,
|
|
||||||
overview: result.overview,
|
var context = {
|
||||||
year: result.releaseDate,
|
id: result.id,
|
||||||
type: "album",
|
title: result.title,
|
||||||
trackCount: result.trackCount,
|
overview: result.overview,
|
||||||
coverArtUrl: result.coverArtUrl,
|
year: result.releaseDate,
|
||||||
artist: result.artist,
|
type: "album",
|
||||||
releaseType: result.releaseType,
|
trackCount: result.trackCount,
|
||||||
country: result.country,
|
coverArtUrl: result.coverArtUrl,
|
||||||
requested: result.requested,
|
artist: result.artist,
|
||||||
approved: result.approved,
|
releaseType: result.releaseType,
|
||||||
available: result.available
|
country: result.country,
|
||||||
};
|
requested: result.requested,
|
||||||
|
approved: result.approved,
|
||||||
return context;
|
available: result.available
|
||||||
}
|
};
|
||||||
|
|
||||||
$('#seasonsModal').on('show.bs.modal', function (event) {
|
return context;
|
||||||
var button = $(event.relatedTarget); // Button that triggered the modal
|
}
|
||||||
var id = button.data('identifier'); // Extract info from data-* attributes
|
|
||||||
var url = createBaseUrl(base, '/search/seasons/');
|
$('#seasonsModal').on('show.bs.modal', function (event) {
|
||||||
|
var button = $(event.relatedTarget); // Button that triggered the modal
|
||||||
$.ajax({
|
var id = button.data('identifier'); // Extract info from data-* attributes
|
||||||
type: "get",
|
var url = createBaseUrl(base, '/search/seasons/');
|
||||||
url: url,
|
|
||||||
data: { tvId: id },
|
$.ajax({
|
||||||
dataType: "json",
|
type: "get",
|
||||||
success: function (results) {
|
url: url,
|
||||||
var $content = $("#seasonsBody");
|
data: { tvId: id },
|
||||||
$('#selectedSeasonsId').val(id);
|
dataType: "json",
|
||||||
results.forEach(function(result) {
|
success: function (results) {
|
||||||
var context = buildSeasonsContext(result);
|
var $content = $("#seasonsBody");
|
||||||
$content.append(seasonsTemplate(context));
|
$content.html("");
|
||||||
});
|
$('#selectedSeasonsId').val(id);
|
||||||
},
|
results.forEach(function(result) {
|
||||||
error: function (e) {
|
var context = buildSeasonsContext(result);
|
||||||
console.log(e);
|
$content.append(seasonsTemplate(context));
|
||||||
generateNotify("Something went wrong!", "danger");
|
});
|
||||||
}
|
},
|
||||||
});
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
function buildSeasonsContext(result) {
|
generateNotify("Something went wrong!", "danger");
|
||||||
var context = {
|
}
|
||||||
id: result
|
});
|
||||||
};
|
|
||||||
return context;
|
function buildSeasonsContext(result) {
|
||||||
};
|
var context = {
|
||||||
});
|
id: result
|
||||||
|
};
|
||||||
$('#seasonsRequest').click(function(e) {
|
return context;
|
||||||
e.preventDefault();
|
};
|
||||||
var tvId = $('#selectedSeasonsId').val();
|
});
|
||||||
var url = createBaseUrl(base, '/search/seasons/');
|
|
||||||
|
$('#seasonsRequest').click(function(e) {
|
||||||
if ($("#" + tvId).attr('disabled')) {
|
e.preventDefault();
|
||||||
return;
|
var tvId = $('#selectedSeasonsId').val();
|
||||||
}
|
var url = createBaseUrl(base, '/search/seasons/');
|
||||||
|
|
||||||
$("#" + tvId).prop("disabled", true);
|
if ($("#" + tvId).attr('disabled')) {
|
||||||
loadingButton(tvId, "primary");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var $form = $('#form' + tvId);
|
$("#" + tvId).prop("disabled", true);
|
||||||
var data = $form.serialize();
|
loadingButton(tvId, "primary");
|
||||||
var seasonsParam = "&seasons=";
|
|
||||||
|
|
||||||
var testimonials = document.querySelectorAll('.selectedSeasons');
|
var $form = $('#form' + tvId);
|
||||||
Array.prototype.forEach.call(testimonials, function (elements, index) {
|
var data = $form.serialize();
|
||||||
seasonsParam = seasonsParam + elements.text() + ",";
|
var seasonsParam = "&seasons=";
|
||||||
});
|
|
||||||
|
var $checkedSeasons = $('.selectedSeasons:checkbox:checked');
|
||||||
data = data + seasonsParam;
|
$checkedSeasons.each(function (index, element) {
|
||||||
|
if (index < $checkedSeasons.length -1) {
|
||||||
var type = $form.prop('method');
|
seasonsParam = seasonsParam + element.id + ",";
|
||||||
var url = $form.prop('action');
|
} else {
|
||||||
|
seasonsParam = seasonsParam + element.id;
|
||||||
sendRequestAjax(data, type, url, tvId);
|
}
|
||||||
|
});
|
||||||
});
|
|
||||||
|
|
||||||
});
|
data = data + seasonsParam;
|
||||||
|
|
||||||
|
var type = $form.prop('method');
|
||||||
|
var url = $form.prop('action');
|
||||||
|
|
||||||
|
sendRequestAjax(data, type, url, tvId);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
|
@ -1,79 +1,79 @@
|
||||||
String.prototype.format = String.prototype.f = function () {
|
String.prototype.format = String.prototype.f = function () {
|
||||||
var s = this,
|
var s = this,
|
||||||
i = arguments.length;
|
i = arguments.length;
|
||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
|
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Humanize(date) {
|
function Humanize(date) {
|
||||||
var mNow = moment();
|
var mNow = moment();
|
||||||
var mDate = moment(date).local();
|
var mDate = moment(date).local();
|
||||||
return moment.duration(mNow - mDate).humanize() + (mNow.isBefore(mDate) ? ' from now' : ' ago');
|
return moment.duration(mNow - mDate).humanize() + (mNow.isBefore(mDate) ? ' from now' : ' ago');
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateNotify(message, type) {
|
function generateNotify(message, type) {
|
||||||
// type = danger, warning, info, successs
|
// type = danger, warning, info, successs
|
||||||
$.notify({
|
$.notify({
|
||||||
// options
|
// options
|
||||||
message: message
|
message: message
|
||||||
}, {
|
}, {
|
||||||
// settings
|
// settings
|
||||||
type: type,
|
type: type,
|
||||||
animate: {
|
animate: {
|
||||||
enter: 'animated bounceInDown',
|
enter: 'animated bounceInDown',
|
||||||
exit: 'animated bounceOutUp'
|
exit: 'animated bounceOutUp'
|
||||||
},
|
},
|
||||||
newest_on_top: true
|
newest_on_top: true
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkJsonResponse(response) {
|
function checkJsonResponse(response) {
|
||||||
if (response.result === true) {
|
if (response.result === true) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
generateNotify(response.message, "warning");
|
generateNotify(response.message, "warning");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadingButton(elementId, originalCss) {
|
function loadingButton(elementId, originalCss) {
|
||||||
var $element = $('#' + elementId);
|
var $element = $('#' + elementId);
|
||||||
$element.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled').html("<i class='fa fa-spinner fa-spin'></i> Loading...");
|
$element.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled').html("<i class='fa fa-spinner fa-spin'></i> Loading...");
|
||||||
|
|
||||||
// handle split-buttons
|
// handle split-buttons
|
||||||
var $dropdown = $element.next('.dropdown-toggle')
|
var $dropdown = $element.next('.dropdown-toggle')
|
||||||
if ($dropdown.length > 0) {
|
if ($dropdown.length > 0) {
|
||||||
$dropdown.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled');
|
$dropdown.removeClass("btn-" + originalCss + "-outline").addClass("btn-primary-outline").addClass('disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishLoading(elementId, originalCss, html) {
|
function finishLoading(elementId, originalCss, html) {
|
||||||
var $element = $('#' + elementId);
|
var $element = $('#' + elementId);
|
||||||
$element.removeClass("btn-primary-outline").removeClass('disabled').addClass("btn-" + originalCss + "-outline").html(html);
|
$element.removeClass("btn-primary-outline").removeClass('disabled').addClass("btn-" + originalCss + "-outline").html(html);
|
||||||
|
|
||||||
// handle split-buttons
|
// handle split-buttons
|
||||||
var $dropdown = $element.next('.dropdown-toggle')
|
var $dropdown = $element.next('.dropdown-toggle')
|
||||||
if ($dropdown.length > 0) {
|
if ($dropdown.length > 0) {
|
||||||
$dropdown.removeClass("btn-primary-outline").removeClass('disabled').addClass("btn-" + originalCss + "-outline");
|
$dropdown.removeClass("btn-primary-outline").removeClass('disabled').addClass("btn-" + originalCss + "-outline");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBaseUrl(base, url) {
|
function createBaseUrl(base, url) {
|
||||||
if (base) {
|
if (base) {
|
||||||
if (url.charAt(0) === "/") {
|
if (url.charAt(0) === "/") {
|
||||||
url = "/" + base + url;
|
url = "/" + base + url;
|
||||||
} else {
|
} else {
|
||||||
url = "/" + base + "/" + url;
|
url = "/" + base + "/" + url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
var noResultsHtml = "<div class='no-search-results'>" +
|
var noResultsHtml = "<div class='no-search-results'>" +
|
||||||
"<i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";
|
"<i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";
|
||||||
var noResultsMusic = "<div class='no-search-results'>" +
|
var noResultsMusic = "<div class='no-search-results'>" +
|
||||||
"<i class='fa fa-headphones no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";
|
"<i class='fa fa-headphones no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";
|
|
@ -68,7 +68,7 @@ namespace PlexRequests.UI.Helpers
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/handlebars.min.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/handlebars.min.js\"></script>");
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/bootstrap.min.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/bootstrap.min.js\"></script>");
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/bootstrap-notify.min.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/bootstrap-notify.min.js\"></script>");
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/site.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/site-1.7.js\"></script>");
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/pace.min.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/pace.min.js\"></script>");
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/jquery.mixitup.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/jquery.mixitup.js\"></script>");
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/moment.min.js\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/moment.min.js\"></script>");
|
||||||
|
@ -84,7 +84,7 @@ namespace PlexRequests.UI.Helpers
|
||||||
|
|
||||||
var content = GetContentUrl(assetLocation);
|
var content = GetContentUrl(assetLocation);
|
||||||
|
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/search.js\" type=\"text/javascript\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/search-1.7.js\" type=\"text/javascript\"></script>");
|
||||||
|
|
||||||
return helper.Raw(sb.ToString());
|
return helper.Raw(sb.ToString());
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ namespace PlexRequests.UI.Helpers
|
||||||
|
|
||||||
var content = GetContentUrl(assetLocation);
|
var content = GetContentUrl(assetLocation);
|
||||||
|
|
||||||
sb.AppendLine($"<script src=\"{content}/Content/requests.js\" type=\"text/javascript\"></script>");
|
sb.AppendLine($"<script src=\"{content}/Content/requests-1.7.js\" type=\"text/javascript\"></script>");
|
||||||
|
|
||||||
return helper.Raw(sb.ToString());
|
return helper.Raw(sb.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@ using PlexRequests.Store;
|
||||||
using PlexRequests.UI.Helpers;
|
using PlexRequests.UI.Helpers;
|
||||||
using PlexRequests.UI.Models;
|
using PlexRequests.UI.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using PlexRequests.Api.Models.Tv;
|
using PlexRequests.Api.Models.Tv;
|
||||||
using PlexRequests.Store.Models;
|
using PlexRequests.Store.Models;
|
||||||
using PlexRequests.Store.Repository;
|
using PlexRequests.Store.Repository;
|
||||||
|
@ -638,9 +640,20 @@ namespace PlexRequests.UI.Modules
|
||||||
seasonsList.Add(model.SeasonCount);
|
seasonsList.Add(model.SeasonCount);
|
||||||
model.SeasonsRequested = "Latest";
|
model.SeasonsRequested = "Latest";
|
||||||
break;
|
break;
|
||||||
default:
|
case "all":
|
||||||
model.SeasonsRequested = "All";
|
model.SeasonsRequested = "All";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
var split = seasons.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var seasonsCount = new int[split.Length];
|
||||||
|
for (var i = 0; i < split.Length; i++)
|
||||||
|
{
|
||||||
|
int tryInt;
|
||||||
|
int.TryParse(split[i], out tryInt);
|
||||||
|
seasonsCount[i] = tryInt;
|
||||||
|
}
|
||||||
|
seasonsList.AddRange(seasonsCount);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
model.SeasonList = seasonsList.ToArray();
|
model.SeasonList = seasonsList.ToArray();
|
||||||
|
|
|
@ -370,10 +370,10 @@
|
||||||
<DependentUpon>pace.css</DependentUpon>
|
<DependentUpon>pace.css</DependentUpon>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\requests.js">
|
<Content Include="Content\requests-1.7.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Content\site.js">
|
<Content Include="Content\site-1.7.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
@ -545,7 +545,7 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Content\search.js">
|
<Content Include="Content\search-1.7.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -280,7 +280,7 @@
|
||||||
<script id="seasons-template" type="text/x-handlebars-template">
|
<script id="seasons-template" type="text/x-handlebars-template">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" class=".selectedSeasons" id="{{id}}" name="{{id}}"><label for="{{id}}">Season {{id}}</label>
|
<input type="checkbox" class="selectedSeasons" id="{{id}}" name="{{id}}"><label for="{{id}}">Season {{id}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue