2011-08-03 09:26:39 +02:00
|
|
|
|
var notIgnoredImage = '../../Content/Images/notIgnored.png';
|
|
|
|
|
var ignoredImage = '../../Content/Images/ignored.png';
|
2011-08-04 03:45:45 +02:00
|
|
|
|
var seriesId = 0;
|
|
|
|
|
var saveSeasonIgnoreUrl = '../Series/SaveSeasonIgnore';
|
|
|
|
|
var saveEpisodeIgnoreUrl = '../Series/SaveEpisodeIgnore';
|
2011-08-22 02:48:37 +02:00
|
|
|
|
var renameEpisodeUrl = '../Episode/Rename';
|
|
|
|
|
var renameSeasonUrl = '../Episode/RenameSeason';
|
|
|
|
|
var searchSeasonUrl = '../Episode/SearchSeason';
|
2011-08-03 09:26:39 +02:00
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
//Episode Ignore Functions
|
2011-08-03 09:26:39 +02:00
|
|
|
|
$(".ignoreEpisode").live("click", function () {
|
|
|
|
|
var toggle = $(this);
|
|
|
|
|
var ignored = toggle.hasClass('ignored');
|
|
|
|
|
|
|
|
|
|
if (ignored) {
|
|
|
|
|
toggle.removeClass('ignored');
|
|
|
|
|
toggle.attr('src', notIgnoredImage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
toggle.addClass('ignored');
|
|
|
|
|
toggle.attr('src', ignoredImage);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-04 03:45:45 +02:00
|
|
|
|
var seasonNumber = 0;
|
2011-08-20 05:02:47 +02:00
|
|
|
|
|
2011-08-04 03:45:45 +02:00
|
|
|
|
//Flip the ignored to the new state (We want the new value moving forward)
|
|
|
|
|
ignored = !ignored;
|
|
|
|
|
|
2011-08-03 09:26:39 +02:00
|
|
|
|
if (toggle.hasClass('ignoredEpisodesMaster')) {
|
2011-08-20 05:02:47 +02:00
|
|
|
|
//seasonNumber = toggle.attr('id').replace('master_', '');
|
|
|
|
|
seasonNumber = toggle.attr('class').split(/\s+/)[2].replace('ignoreSeason_', '');
|
2011-08-03 09:26:39 +02:00
|
|
|
|
|
|
|
|
|
toggleChildren(seasonNumber, ignored);
|
2011-08-20 05:02:47 +02:00
|
|
|
|
toggleMasters(seasonNumber, ignored);
|
2011-08-04 03:45:45 +02:00
|
|
|
|
saveSeasonIgnore(seasonNumber, ignored);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
//Check to see if this is the last one ignored or the first not ignored
|
|
|
|
|
seasonNumber = toggle.attr('class').split(/\s+/)[1].replace('ignoreEpisode_', '');
|
|
|
|
|
var episodeId = toggle.attr('id');
|
|
|
|
|
toggleMaster(seasonNumber, ignored);
|
|
|
|
|
saveEpisodeIgnore(episodeId, ignored);
|
2011-08-03 09:26:39 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function toggleChildren(seasonNumber, ignored) {
|
|
|
|
|
var ignoreEpisodes = $('.ignoreEpisode_' + seasonNumber);
|
|
|
|
|
|
2011-08-04 03:45:45 +02:00
|
|
|
|
if (ignored) {
|
2011-08-03 09:26:39 +02:00
|
|
|
|
ignoreEpisodes.each(function (index) {
|
|
|
|
|
$(this).addClass('ignored');
|
|
|
|
|
$(this).attr('src', ignoredImage);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
ignoreEpisodes.each(function (index) {
|
|
|
|
|
$(this).removeClass('ignored');
|
|
|
|
|
$(this).attr('src', notIgnoredImage);
|
|
|
|
|
});
|
2011-08-04 03:45:45 +02:00
|
|
|
|
}
|
2011-08-03 09:26:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-04 03:45:45 +02:00
|
|
|
|
function toggleMaster(seasonNumber) {
|
|
|
|
|
var ignoreEpisodes = $('.ignoreEpisode_' + seasonNumber);
|
|
|
|
|
var ignoredCount = ignoreEpisodes.filter('.ignored').length;
|
2011-08-20 05:02:47 +02:00
|
|
|
|
var masters = $('.ignoreSeason_' + seasonNumber);
|
|
|
|
|
|
|
|
|
|
masters.each(function (index) {
|
|
|
|
|
if (ignoreEpisodes.length == ignoredCount) {
|
|
|
|
|
$(this).attr('src', ignoredImage);
|
|
|
|
|
$(this).addClass('ignored');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
$(this).attr('src', notIgnoredImage);
|
|
|
|
|
$(this).removeClass('ignored');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleMasters(seasonNumber, ignored) {
|
|
|
|
|
var masters = $('.ignoreSeason_' + seasonNumber);
|
|
|
|
|
|
|
|
|
|
if (ignored) {
|
|
|
|
|
masters.each(function (index) {
|
|
|
|
|
$(this).addClass('ignored');
|
|
|
|
|
$(this).attr('src', ignoredImage);
|
|
|
|
|
});
|
2011-08-04 03:45:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
2011-08-20 05:02:47 +02:00
|
|
|
|
masters.each(function (index) {
|
|
|
|
|
$(this).removeClass('ignored');
|
|
|
|
|
$(this).attr('src', notIgnoredImage);
|
|
|
|
|
});
|
2011-08-04 03:45:45 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Functions called by the Telerik Season Grid
|
2011-08-03 09:26:39 +02:00
|
|
|
|
function grid_rowBound(e) {
|
|
|
|
|
var dataItem = e.dataItem;
|
|
|
|
|
var ignored = dataItem.Ignored;
|
|
|
|
|
var episodeId = dataItem.EpisodeId;
|
|
|
|
|
|
|
|
|
|
var ignoredIcon = $('#' + episodeId);
|
|
|
|
|
|
|
|
|
|
if (ignored) {
|
|
|
|
|
ignoredIcon.attr('src', ignoredImage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
ignoredIcon.attr('src', notIgnoredImage);
|
|
|
|
|
ignoredIcon.removeClass('ignored');
|
|
|
|
|
}
|
2011-08-20 05:02:47 +02:00
|
|
|
|
|
2011-08-04 03:45:45 +02:00
|
|
|
|
if (seriesId == 0)
|
2011-08-20 05:02:47 +02:00
|
|
|
|
seriesId = dataItem.SeriesId;
|
2011-08-03 09:26:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grid_dataBound(e) {
|
|
|
|
|
var id = $(this).attr('id');
|
|
|
|
|
var seasonNumber = id.replace('seasons_', '');
|
|
|
|
|
|
2011-08-20 05:02:47 +02:00
|
|
|
|
toggleMaster(seasonNumber);
|
2011-08-04 03:45:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:37 +02:00
|
|
|
|
//Episode Ignore Saving
|
2011-08-04 03:45:45 +02:00
|
|
|
|
function saveSeasonIgnore(seasonNumber, ignored) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: saveSeasonIgnoreUrl,
|
|
|
|
|
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber, ignored: ignored }),
|
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could save the ignore settings for Series: " + seriesId + ", Season: " + seasonNumber + " at this time. " + error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveEpisodeIgnore(episodeId, ignored) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: saveEpisodeIgnoreUrl,
|
|
|
|
|
data: jQuery.param({ episodeId: episodeId, ignored: ignored }),
|
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could save the ignore settings for Episode: " + episodeId + " at this time. " + error);
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-08-22 02:48:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Episode Renaming
|
|
|
|
|
function renameEpisode(id) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: renameEpisodeUrl,
|
|
|
|
|
data: jQuery.param({ episodeFileId: id }),
|
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could rename " + id + " at this time. " + error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renameSeason(seriesId, seasonNumber) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: renameSeasonUrl,
|
|
|
|
|
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber }),
|
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could rename series: " + seriesId + " season: " + seasonNumber + " at this time. " + error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Season Search
|
|
|
|
|
function searchSeason(seriesId, seasonNumber) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: searchSeasonUrl,
|
|
|
|
|
data: jQuery.param({ seriesId: seriesId, seasonNumber: seasonNumber }),
|
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could search for series: " + seriesId + " season: " + seasonNumber + " at this time. " + error);
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-08-03 09:26:39 +02:00
|
|
|
|
}
|