2012-10-11 05:02:17 +03:00
|
|
|
var seriesId = 0;
|
2012-10-28 22:15:56 +03:00
|
|
|
var saveSeasonIgnoreUrl = '/command/saveseasonignore';
|
|
|
|
var saveEpisodeIgnoreUrl = '/command/saveepisodeignore';
|
2011-08-03 10:26:39 +03:00
|
|
|
|
2012-09-04 02:26:52 +03:00
|
|
|
var changeQualityType;
|
|
|
|
var changeQualityData;
|
2012-10-28 22:15:56 +03:00
|
|
|
var changeEpisodeQualityUrl = '/episode/changeepisodequality';
|
|
|
|
var changeSeasonQualityUrl = '/episode/changeseasonquality';
|
2012-09-04 02:26:52 +03:00
|
|
|
|
2011-08-22 03:48:37 +03:00
|
|
|
//Episode Ignore Functions
|
2011-08-03 10:26:39 +03:00
|
|
|
$(".ignoreEpisode").live("click", function () {
|
|
|
|
var toggle = $(this);
|
|
|
|
var ignored = toggle.hasClass('ignored');
|
|
|
|
|
|
|
|
if (ignored) {
|
|
|
|
toggle.removeClass('ignored');
|
2012-02-04 10:36:52 +03:00
|
|
|
toggleCellColour(toggle, false);
|
2011-08-03 10:26:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
toggle.addClass('ignored');
|
2012-02-04 10:36:52 +03:00
|
|
|
toggleCellColour(toggle, true);
|
2011-08-03 10:26:39 +03:00
|
|
|
}
|
|
|
|
|
2011-08-04 04:45:45 +03:00
|
|
|
var seasonNumber = 0;
|
2011-08-20 06:02:47 +03:00
|
|
|
|
2011-08-04 04:45:45 +03:00
|
|
|
//Flip the ignored to the new state (We want the new value moving forward)
|
|
|
|
ignored = !ignored;
|
|
|
|
|
2011-08-03 10:26:39 +03:00
|
|
|
if (toggle.hasClass('ignoredEpisodesMaster')) {
|
2012-10-01 02:06:59 +03:00
|
|
|
seasonNumber = toggle.attr('data-season');
|
2011-08-03 10:26:39 +03:00
|
|
|
|
|
|
|
toggleChildren(seasonNumber, ignored);
|
2011-08-20 06:02:47 +03:00
|
|
|
toggleMasters(seasonNumber, ignored);
|
2011-08-04 04:45:45 +03:00
|
|
|
saveSeasonIgnore(seasonNumber, ignored);
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
//Check to see if this is the last one ignored or the first not ignored
|
2012-10-01 02:06:59 +03:00
|
|
|
var episodeId = toggle.attr('data-episode-id');
|
2011-08-04 04:45:45 +03:00
|
|
|
saveEpisodeIgnore(episodeId, ignored);
|
2011-08-03 10:26:39 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function toggleChildren(seasonNumber, ignored) {
|
2012-10-11 05:02:17 +03:00
|
|
|
var ignoreEpisodes = $('[data-season="' + seasonNumber + '"]:not(table)');
|
2011-08-03 10:26:39 +03:00
|
|
|
|
2011-08-04 04:45:45 +03:00
|
|
|
if (ignored) {
|
2011-08-03 10:26:39 +03:00
|
|
|
ignoreEpisodes.each(function (index) {
|
|
|
|
$(this).addClass('ignored');
|
2012-02-04 10:36:52 +03:00
|
|
|
toggleCellColour($(this), true);
|
2011-08-03 10:26:39 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
ignoreEpisodes.each(function (index) {
|
|
|
|
$(this).removeClass('ignored');
|
2012-02-04 10:36:52 +03:00
|
|
|
|
|
|
|
toggleCellColour($(this), false);
|
2011-08-03 10:26:39 +03:00
|
|
|
});
|
2011-08-04 04:45:45 +03:00
|
|
|
}
|
2011-08-03 10:26:39 +03:00
|
|
|
}
|
|
|
|
|
2011-08-20 06:02:47 +03:00
|
|
|
function toggleMasters(seasonNumber, ignored) {
|
2011-08-23 06:52:08 +03:00
|
|
|
//Toggles the other master(s) to match the one that was just changed
|
2011-08-20 06:02:47 +03:00
|
|
|
var masters = $('.ignoreSeason_' + seasonNumber);
|
|
|
|
|
|
|
|
if (ignored) {
|
|
|
|
masters.each(function (index) {
|
|
|
|
$(this).addClass('ignored');
|
|
|
|
});
|
2011-08-04 04:45:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2011-08-20 06:02:47 +03:00
|
|
|
masters.each(function (index) {
|
|
|
|
$(this).removeClass('ignored');
|
|
|
|
});
|
2011-08-04 04:45:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-04 10:36:52 +03:00
|
|
|
function toggleCellColour(toggle, ignored) {
|
2011-08-03 10:26:39 +03:00
|
|
|
if (ignored) {
|
2012-02-04 10:36:52 +03:00
|
|
|
toggle.parent('td').addClass('episodeIgnored');
|
|
|
|
toggle.parent('td').removeClass('episodeMissing');
|
2011-08-03 10:26:39 +03:00
|
|
|
}
|
2012-02-04 10:36:52 +03:00
|
|
|
|
2011-08-03 10:26:39 +03:00
|
|
|
else {
|
2012-02-04 10:36:52 +03:00
|
|
|
toggle.parent('td').removeClass('episodeIgnored');
|
2011-08-20 06:02:47 +03:00
|
|
|
|
2012-02-04 10:36:52 +03:00
|
|
|
//check to see if episode is missing
|
2012-10-01 02:06:59 +03:00
|
|
|
if (toggle.parent('td').children('.statusImage').attr('data-status') === 'Missing')
|
2012-02-04 10:36:52 +03:00
|
|
|
toggle.parent('td').addClass('episodeMissing');
|
|
|
|
}
|
2011-08-04 04:45:45 +03:00
|
|
|
}
|
|
|
|
|
2011-08-22 03:48:37 +03:00
|
|
|
//Episode Ignore Saving
|
2011-08-04 04:45:45 +03:00
|
|
|
function saveSeasonIgnore(seasonNumber, ignored) {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: saveSeasonIgnoreUrl,
|
|
|
|
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber, ignored: ignored }),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveEpisodeIgnore(episodeId, ignored) {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: saveEpisodeIgnoreUrl,
|
|
|
|
data: jQuery.param({ episodeId: episodeId, ignored: ignored }),
|
|
|
|
});
|
2012-09-04 02:26:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//Change quality
|
|
|
|
$(document).on('click', '.changeQuality', function() {
|
|
|
|
changeQualityType = $(this).attr('data-changetype');
|
|
|
|
|
|
|
|
if (changeQualityType === "episode") {
|
|
|
|
var row = $(this).closest('tr');
|
|
|
|
|
|
|
|
changeQualityData = $(row).attr('data-episodefileid');
|
|
|
|
|
|
|
|
if (changeQualityData === "0")
|
|
|
|
return;
|
|
|
|
|
|
|
|
var qualityId = $(row).find('.episodeQuality').attr('data-qualityid');
|
|
|
|
$('#NewQuality').val(qualityId);
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
changeQualityData = $(this).closest('table').attr('data-season');
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#qualityChanger').dialog('open');
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#qualityChanger").dialog({
|
|
|
|
autoOpen: false,
|
|
|
|
height: 'auto',
|
|
|
|
width: 670,
|
|
|
|
resizable: false,
|
|
|
|
modal: true,
|
|
|
|
buttons: {
|
|
|
|
"Save": function () {
|
|
|
|
//Save the quality
|
|
|
|
var newQualityId = $('#NewQuality').val();
|
|
|
|
var newQualityText = $('#NewQuality :selected').text();
|
|
|
|
|
|
|
|
if (changeQualityType === "episode") {
|
|
|
|
$.ajax({
|
|
|
|
url: changeEpisodeQualityUrl,
|
|
|
|
data: { episodeFileId: changeQualityData, quality: newQualityId },
|
|
|
|
type: 'POST',
|
|
|
|
success: function(data) {
|
|
|
|
var row = $('tr[data-episodefileid="' + changeQualityData + '"]');
|
|
|
|
var qualityCell = $(row).find('.episodeQuality');
|
|
|
|
$(qualityCell).attr('data-qualityid', newQualityId);
|
|
|
|
$(qualityCell).text(newQualityText);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
$.ajax({
|
|
|
|
url: changeSeasonQualityUrl,
|
|
|
|
data: { seriesId: seriesId, seasonNumber: changeQualityData, quality: newQualityId },
|
|
|
|
type: 'POST',
|
|
|
|
success: function (data) {
|
|
|
|
var table = $('table[data-season="' + changeQualityData + '"]');
|
2012-09-05 08:25:38 +03:00
|
|
|
var rows = $(table).find('tbody').children('tr');
|
2012-09-04 02:26:52 +03:00
|
|
|
|
|
|
|
$(rows).each(function() {
|
2012-09-05 08:25:38 +03:00
|
|
|
if ($(this).attr('data-episodefileid') === '0')
|
2012-09-04 02:26:52 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
var qualityCell = $(this).find('.episodeQuality');
|
|
|
|
$(qualityCell).attr('data-qualityid', newQualityId);
|
|
|
|
$(qualityCell).text(newQualityText);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(this).dialog("close");
|
|
|
|
},
|
|
|
|
Cancel: function () {
|
|
|
|
$(this).dialog("close");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|