2017-11-27 19:35:20 +00:00
|
|
|
$(document).ready(function() {
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2017-11-27 19:35:20 +00:00
|
|
|
function make_row(indexer_id, season, episode, name, checked, airdate_never, qualityCss, qualityStr, sxe) {
|
2015-02-25 23:19:52 +00:00
|
|
|
var checkedbox = (checked ? ' checked' : ''),
|
2015-03-18 22:22:54 +00:00
|
|
|
row_class = $('#row_class').val(),
|
|
|
|
ep_id = season + 'x' + episode;
|
2014-12-13 15:47:58 +00:00
|
|
|
|
2015-03-18 22:22:54 +00:00
|
|
|
return ' <tr id="ep-' + indexer_id + '-' + ep_id + '" class="' + (airdate_never ? 'airdate-never' : row_class) + '">'
|
2015-02-25 23:19:52 +00:00
|
|
|
+ ' <td class="tableleft" align="center">'
|
|
|
|
+ '<input type="checkbox"'
|
|
|
|
+ ' class="' + indexer_id + '-epcheck"'
|
2015-03-18 22:22:54 +00:00
|
|
|
+ ' name="' + indexer_id + '-' + ep_id + '"'
|
2015-02-25 23:19:52 +00:00
|
|
|
+ checkedbox+'></td>'
|
2017-11-27 19:35:20 +00:00
|
|
|
+ ' <td class="text-nowrap">' + sxe + '</td>'
|
|
|
|
+ ' <td class="tableright" style="width: 100%">'
|
|
|
|
+ ' <span class="quality show-quality ' + qualityCss + ' text-nowrap">' + qualityStr + '</span>'
|
|
|
|
+ name + (airdate_never ? ' (<strong><em>airdate is never, this should change in time</em></strong>)' : '') + '</td>'
|
2015-02-25 23:19:52 +00:00
|
|
|
+ ' </tr>';
|
|
|
|
}
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-25 23:19:52 +00:00
|
|
|
$('.go').click(function() {
|
2015-02-28 03:05:20 +00:00
|
|
|
if ($('input[class*="-epcheck"]:checked').length === 0 && $('input[id*="allCheck-"]:checked').length === 0) {
|
|
|
|
alert('Please select at least one Show or Episode');
|
|
|
|
return false
|
|
|
|
}
|
2015-02-25 23:19:52 +00:00
|
|
|
});
|
2014-12-13 15:47:58 +00:00
|
|
|
|
2015-02-25 23:19:52 +00:00
|
|
|
$('.allCheck').click(function(){
|
|
|
|
var indexer_id = $(this).attr('id').split('-')[1];
|
|
|
|
$('.' + indexer_id + '-epcheck').prop('checked', $(this).prop('checked'));
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-03-18 22:22:54 +00:00
|
|
|
$('.get_more_eps').show();
|
|
|
|
function show_episodes(btn_element) {
|
|
|
|
var match = btn_element.attr('id').match(/(.*)[-](.*)/);
|
|
|
|
if (null == match)
|
|
|
|
return false;
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-03-18 22:22:54 +00:00
|
|
|
var cur_indexer_id = match[1], action = match[2], checked = $('#allCheck-' + cur_indexer_id).prop('checked'),
|
|
|
|
show_header = $('tr#' + cur_indexer_id), episode_rows = $('tr[id*="ep-' + cur_indexer_id + '"]'),
|
|
|
|
void_var = 'more' == action && episode_rows.show() || episode_rows.hide();
|
|
|
|
|
|
|
|
$('input#' + match[0]).val('more' == action ? 'Expanding...' : 'Collapsing...');
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-03-18 22:22:54 +00:00
|
|
|
if (0 == episode_rows.length) {
|
2015-02-25 23:19:52 +00:00
|
|
|
$.getJSON(sbRoot + '/manage/showEpisodeStatuses',
|
|
|
|
{
|
|
|
|
indexer_id: cur_indexer_id,
|
|
|
|
whichStatus: $('#oldStatus').val()
|
|
|
|
},
|
|
|
|
function (data) {
|
2015-03-18 22:22:54 +00:00
|
|
|
$.each(data, function(season, eps){
|
|
|
|
$.each(eps, function(episode, meta) {
|
2017-11-27 19:35:20 +00:00
|
|
|
show_header.after(make_row(cur_indexer_id, season, episode, meta.name, checked, meta.airdate_never, meta.qualityCss, meta.qualityStr, meta.sxe));
|
2015-02-25 23:19:52 +00:00
|
|
|
});
|
|
|
|
});
|
2015-03-18 22:22:54 +00:00
|
|
|
$('input#' + match[0]).val('more' == action ? 'Expand' : 'Collapse');
|
|
|
|
btn_element.hide();
|
|
|
|
$('input[id="' + cur_indexer_id + '-' + ('more' == action ? 'less' : 'more') + '"]').show();
|
2015-02-25 23:19:52 +00:00
|
|
|
});
|
2015-03-18 22:22:54 +00:00
|
|
|
} else {
|
|
|
|
$('input#' + match[0]).val('more' == action ? 'Expand' : 'Collapse');
|
|
|
|
btn_element.hide();
|
|
|
|
$('input[id="' + cur_indexer_id + '-' + ('more' == action ? 'less' : 'more') + '"]').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.get_more_eps,.get_less_eps').click(function(){
|
|
|
|
show_episodes($(this));
|
|
|
|
($('.get_more_eps:visible').length == 0 ? $('.expandAll').hide() : '');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.expandAll').click(function() {
|
2015-02-25 23:19:52 +00:00
|
|
|
$(this).hide();
|
2015-03-18 22:22:54 +00:00
|
|
|
$('.get_more_eps').each(function() {
|
|
|
|
show_episodes($(this));
|
|
|
|
});
|
2015-02-25 23:19:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// selects all visible episode checkboxes.
|
|
|
|
$('.selectAllShows').click(function(){
|
|
|
|
$('.sickbeardTable input').each(function() {
|
|
|
|
this.checked = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// clears all visible episode checkboxes and the season selectors
|
|
|
|
$('.unselectAllShows').click(function(){
|
|
|
|
$('.sickbeardTable input').each(function() {
|
|
|
|
this.checked = false;
|
|
|
|
});
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2017-11-27 19:35:20 +00:00
|
|
|
});
|