mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
#131 fix for default selected tab
This commit is contained in:
parent
c52ca41e32
commit
96fde83488
1 changed files with 250 additions and 239 deletions
|
@ -5,283 +5,294 @@
|
||||||
return opts.inverse(this);
|
return opts.inverse(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
var searchSource = $("#search-template").html();
|
$(function () {
|
||||||
var musicSource = $("#music-template").html();
|
|
||||||
var searchTemplate = Handlebars.compile(searchSource);
|
|
||||||
var musicTemplate = Handlebars.compile(musicSource);
|
|
||||||
|
|
||||||
var searchTimer = 0;
|
var searchSource = $("#search-template").html();
|
||||||
|
var musicSource = $("#music-template").html();
|
||||||
|
var searchTemplate = Handlebars.compile(searchSource);
|
||||||
|
var musicTemplate = Handlebars.compile(musicSource);
|
||||||
|
|
||||||
// Type in movie search
|
var searchTimer = 0;
|
||||||
$("#movieSearchContent").on("input", function () {
|
|
||||||
if (searchTimer) {
|
|
||||||
clearTimeout(searchTimer);
|
|
||||||
}
|
|
||||||
$('#movieSearchButton').attr("class","fa fa-spinner fa-spin");
|
|
||||||
searchTimer = setTimeout(movieSearch, 400);
|
|
||||||
|
|
||||||
});
|
// fix for selecting a default tab
|
||||||
|
var $tabs = $('#nav-tabs').children('li');
|
||||||
$('#moviesComingSoon').on('click', function (e) {
|
if ($tabs.filter(function (li) { return $(li).hasClass('active') }).length <= 0) {
|
||||||
e.preventDefault();
|
$tabs.first().children('a:first-child').tab('show');
|
||||||
moviesComingSoon();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#moviesInTheaters').on('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
moviesInTheaters();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Type in TV search
|
|
||||||
$("#tvSearchContent").on("input", function () {
|
|
||||||
if (searchTimer) {
|
|
||||||
clearTimeout(searchTimer);
|
|
||||||
}
|
|
||||||
$('#tvSearchButton').attr("class", "fa fa-spinner fa-spin");
|
|
||||||
searchTimer = setTimeout(tvSearch, 400);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Click TV dropdown option
|
|
||||||
$(document).on("click", ".dropdownTv", function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var buttonId = e.target.id;
|
|
||||||
if ($("#" + buttonId).attr('disabled')) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#" + buttonId).prop("disabled", true);
|
|
||||||
loadingButton(buttonId, "primary");
|
// Type in movie search
|
||||||
|
$("#movieSearchContent").on("input", function () {
|
||||||
|
if (searchTimer) {
|
||||||
|
clearTimeout(searchTimer);
|
||||||
|
}
|
||||||
|
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||||
|
searchTimer = setTimeout(movieSearch, 400);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#moviesComingSoon').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
moviesComingSoon();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#moviesInTheaters').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
moviesInTheaters();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Type in TV search
|
||||||
|
$("#tvSearchContent").on("input", function () {
|
||||||
|
if (searchTimer) {
|
||||||
|
clearTimeout(searchTimer);
|
||||||
|
}
|
||||||
|
$('#tvSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||||
|
searchTimer = setTimeout(tvSearch, 400);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Click TV dropdown option
|
||||||
|
$(document).on("click", ".dropdownTv", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var buttonId = e.target.id;
|
||||||
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#" + buttonId).prop("disabled", true);
|
||||||
|
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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = $form.prop('method');
|
var type = $form.prop('method');
|
||||||
var url = $form.prop('action');
|
var url = $form.prop('action');
|
||||||
|
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Search Music
|
// Search Music
|
||||||
$("#musicSearchContent").on("input", function () {
|
$("#musicSearchContent").on("input", function () {
|
||||||
if (searchTimer) {
|
if (searchTimer) {
|
||||||
clearTimeout(searchTimer);
|
clearTimeout(searchTimer);
|
||||||
}
|
}
|
||||||
$('#musicSearchButton').attr("class", "fa fa-spinner fa-spin");
|
$('#musicSearchButton').attr("class", "fa fa-spinner fa-spin");
|
||||||
searchTimer = setTimeout(musicSearch, 400);
|
searchTimer = setTimeout(musicSearch, 400);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Click Request for movie
|
// Click Request for movie
|
||||||
$(document).on("click", ".requestMovie", function (e) {
|
$(document).on("click", ".requestMovie", 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 type = $form.prop('method');
|
var type = $form.prop('method');
|
||||||
var url = $form.prop('action');
|
var url = $form.prop('action');
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
|
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Click Request for album
|
});
|
||||||
$(document).on("click", ".requestAlbum", function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var buttonId = e.target.id;
|
|
||||||
if ($("#" + buttonId).attr('disabled')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#" + buttonId).prop("disabled", true);
|
// Click Request for album
|
||||||
loadingButton(buttonId, "primary");
|
$(document).on("click", ".requestAlbum", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var buttonId = e.target.id;
|
||||||
|
if ($("#" + buttonId).attr('disabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#" + buttonId).prop("disabled", true);
|
||||||
|
loadingButton(buttonId, "primary");
|
||||||
|
|
||||||
|
|
||||||
var $form = $('#form' + buttonId);
|
var $form = $('#form' + buttonId);
|
||||||
|
|
||||||
var type = $form.prop('method');
|
var type = $form.prop('method');
|
||||||
var url = $form.prop('action');
|
var url = $form.prop('action');
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
|
|
||||||
sendRequestAjax(data, type, url, buttonId);
|
sendRequestAjax(data, type, url, buttonId);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendRequestAjax(data, type, url, buttonId) {
|
function sendRequestAjax(data, type, url, buttonId) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: type,
|
type: type,
|
||||||
url: url,
|
url: url,
|
||||||
data: data,
|
data: data,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if (response.result === true) {
|
if (response.result === true) {
|
||||||
generateNotify(response.message || "Success!", "success");
|
generateNotify(response.message || "Success!", "success");
|
||||||
|
|
||||||
$('#' + buttonId).html("<i class='fa fa-check'></i> Requested");
|
$('#' + buttonId).html("<i class='fa fa-check'></i> Requested");
|
||||||
$('#' + buttonId).removeClass("btn-primary-outline");
|
$('#' + buttonId).removeClass("btn-primary-outline");
|
||||||
$('#' + buttonId).removeAttr("data-toggle");
|
$('#' + buttonId).removeAttr("data-toggle");
|
||||||
$('#' + buttonId).addClass("btn-success-outline");
|
$('#' + buttonId).addClass("btn-success-outline");
|
||||||
} else {
|
} else {
|
||||||
generateNotify(response.message, "warning");
|
generateNotify(response.message, "warning");
|
||||||
$('#' + buttonId).html("<i class='fa fa-plus'></i> Request");
|
$('#' + buttonId).html("<i class='fa fa-plus'></i> Request");
|
||||||
$('#' + buttonId).attr("data-toggle", "dropdown");
|
$('#' + buttonId).attr("data-toggle", "dropdown");
|
||||||
$("#" + buttonId).removeAttr("disabled");
|
$("#" + buttonId).removeAttr("disabled");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
error: function (e) {
|
}
|
||||||
console.log(e);
|
|
||||||
generateNotify("Something went wrong!", "danger");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function movieSearch() {
|
function movieSearch() {
|
||||||
var query = $("#movieSearchContent").val();
|
var query = $("#movieSearchContent").val();
|
||||||
getMovies("/search/movie/" + query);
|
getMovies("/search/movie/" + query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moviesComingSoon() {
|
function moviesComingSoon() {
|
||||||
getMovies("/search/movie/upcoming");
|
getMovies("/search/movie/upcoming");
|
||||||
}
|
}
|
||||||
|
|
||||||
function moviesInTheaters() {
|
function moviesInTheaters() {
|
||||||
getMovies("/search/movie/playing");
|
getMovies("/search/movie/playing");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMovies(url) {
|
function getMovies(url) {
|
||||||
$("#movieList").html("");
|
$("#movieList").html("");
|
||||||
|
|
||||||
|
|
||||||
$.ajax(url).success(function (results) {
|
|
||||||
if (results.length > 0) {
|
|
||||||
results.forEach(function(result) {
|
|
||||||
var context = buildMovieContext(result);
|
|
||||||
|
|
||||||
var html = searchTemplate(context);
|
$.ajax(url).success(function (results) {
|
||||||
$("#movieList").append(html);
|
if (results.length > 0) {
|
||||||
});
|
results.forEach(function (result) {
|
||||||
}
|
var context = buildMovieContext(result);
|
||||||
else {
|
|
||||||
$("#movieList").html(noResultsHtml);
|
|
||||||
}
|
|
||||||
$('#movieSearchButton').attr("class","fa fa-search");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function tvSearch() {
|
var html = searchTemplate(context);
|
||||||
var query = $("#tvSearchContent").val();
|
$("#movieList").append(html);
|
||||||
getTvShows("/search/tv/" + query);
|
});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
function getTvShows(url) {
|
$("#movieList").html(noResultsHtml);
|
||||||
$("#tvList").html("");
|
}
|
||||||
|
$('#movieSearchButton').attr("class", "fa fa-search");
|
||||||
$.ajax(url).success(function (results) {
|
});
|
||||||
if (results.length > 0) {
|
|
||||||
results.forEach(function(result) {
|
|
||||||
var context = buildTvShowContext(result);
|
|
||||||
var html = searchTemplate(context);
|
|
||||||
$("#tvList").append(html);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$("#tvList").html(noResultsHtml);
|
|
||||||
}
|
|
||||||
$('#tvSearchButton').attr("class", "fa fa-search");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function musicSearch() {
|
|
||||||
var query = $("#musicSearchContent").val();
|
|
||||||
getMusic("/search/music/" + query);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMusic(url) {
|
|
||||||
$("#musicList").html("");
|
|
||||||
|
|
||||||
$.ajax(url).success(function (results) {
|
|
||||||
if (results.length > 0) {
|
|
||||||
results.forEach(function (result) {
|
|
||||||
var context = buildMusicContext(result);
|
|
||||||
|
|
||||||
var html = musicTemplate(context);
|
|
||||||
$("#musicList").append(html);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$("#musicList").html(noResultsMusic);
|
|
||||||
}
|
|
||||||
$('#musicSearchButton').attr("class", "fa fa-search");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
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",
|
|
||||||
imdb: result.imdbId
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return context;
|
function tvSearch() {
|
||||||
}
|
var query = $("#tvSearchContent").val();
|
||||||
|
getTvShows("/search/tv/" + query);
|
||||||
|
}
|
||||||
|
|
||||||
function buildTvShowContext(result) {
|
function getTvShows(url) {
|
||||||
var date = new Date(result.firstAired);
|
$("#tvList").html("");
|
||||||
var year = date.getFullYear();
|
|
||||||
var context = {
|
|
||||||
posterPath: result.banner,
|
|
||||||
id: result.id,
|
|
||||||
title: result.seriesName,
|
|
||||||
overview: result.overview,
|
|
||||||
year: year,
|
|
||||||
type: "tv",
|
|
||||||
imdb: result.imdbId
|
|
||||||
};
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildMusicContext(result) {
|
$.ajax(url).success(function (results) {
|
||||||
|
if (results.length > 0) {
|
||||||
var context = {
|
results.forEach(function (result) {
|
||||||
id: result.id,
|
var context = buildTvShowContext(result);
|
||||||
title: result.title,
|
var html = searchTemplate(context);
|
||||||
overview: result.overview,
|
$("#tvList").append(html);
|
||||||
year: result.releaseDate,
|
});
|
||||||
type: "album",
|
}
|
||||||
trackCount: result.trackCount,
|
else {
|
||||||
coverArtUrl: result.coverArtUrl,
|
$("#tvList").html(noResultsHtml);
|
||||||
artist: result.artist,
|
}
|
||||||
releaseType: result.releaseType,
|
$('#tvSearchButton').attr("class", "fa fa-search");
|
||||||
country: result.country
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return context;
|
function musicSearch() {
|
||||||
}
|
var query = $("#musicSearchContent").val();
|
||||||
|
getMusic("/search/music/" + query);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMusic(url) {
|
||||||
|
$("#musicList").html("");
|
||||||
|
|
||||||
|
$.ajax(url).success(function (results) {
|
||||||
|
if (results.length > 0) {
|
||||||
|
results.forEach(function (result) {
|
||||||
|
var context = buildMusicContext(result);
|
||||||
|
|
||||||
|
var html = musicTemplate(context);
|
||||||
|
$("#musicList").append(html);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#musicList").html(noResultsMusic);
|
||||||
|
}
|
||||||
|
$('#musicSearchButton').attr("class", "fa fa-search");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
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",
|
||||||
|
imdb: result.imdbId
|
||||||
|
};
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildTvShowContext(result) {
|
||||||
|
var date = new Date(result.firstAired);
|
||||||
|
var year = date.getFullYear();
|
||||||
|
var context = {
|
||||||
|
posterPath: result.banner,
|
||||||
|
id: result.id,
|
||||||
|
title: result.seriesName,
|
||||||
|
overview: result.overview,
|
||||||
|
year: year,
|
||||||
|
type: "tv",
|
||||||
|
imdb: result.imdbId
|
||||||
|
};
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildMusicContext(result) {
|
||||||
|
|
||||||
|
var context = {
|
||||||
|
id: result.id,
|
||||||
|
title: result.title,
|
||||||
|
overview: result.overview,
|
||||||
|
year: result.releaseDate,
|
||||||
|
type: "album",
|
||||||
|
trackCount: result.trackCount,
|
||||||
|
coverArtUrl: result.coverArtUrl,
|
||||||
|
artist: result.artist,
|
||||||
|
releaseType: result.releaseType,
|
||||||
|
country: result.country
|
||||||
|
};
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue