2011-08-23 20:31:28 +00:00
|
|
|
|
//URLs
|
|
|
|
|
var addSeriesUrl = '../AddSeries/AddExistingSeries';
|
|
|
|
|
var addNewSeriesUrl = '../AddSeries/AddNewSeries';
|
2011-10-19 15:16:34 +00:00
|
|
|
|
var quickAddNewSeriesUrl = '../AddSeries/QuickAddNewSeries';
|
2011-08-23 20:31:28 +00:00
|
|
|
|
var existingSeriesUrl = '../AddSeries/ExistingSeries';
|
|
|
|
|
var addNewUrl = '../AddSeries/AddNew';
|
|
|
|
|
|
|
|
|
|
var deleteRootDirUrl = '../AddSeries/DeleteRootDir';
|
|
|
|
|
var saveRootDirUrl = '../AddSeries/SaveRootDir';
|
|
|
|
|
var rootListUrl = '../AddSeries/RootList';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ExistingSeries
|
|
|
|
|
$(".masterQualitySelector").live('change', function () {
|
|
|
|
|
|
|
|
|
|
var profileId = $(this).val();
|
2011-12-12 01:22:10 +00:00
|
|
|
|
$("#existingSeries").find(".qualitySelector").each(function () {
|
2011-08-23 20:31:28 +00:00
|
|
|
|
$(this).val(profileId);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(".addExistingButton").live('click', function () {
|
|
|
|
|
var root = $(this).parents(".existingSeries");
|
|
|
|
|
var title = $(this).siblings(".seriesLookup").val();
|
2011-09-09 03:52:25 +00:00
|
|
|
|
var seriesId = $(this).siblings(".seriesId").val();
|
2011-08-23 20:31:28 +00:00
|
|
|
|
var qualityId = $(this).siblings(".qualitySelector").val();
|
|
|
|
|
|
|
|
|
|
var path = root.find(".seriesPathValue Label").text();
|
|
|
|
|
|
2012-01-13 16:54:20 +00:00
|
|
|
|
if (seriesId === 0 || $.trim(title).length === 0) {
|
2012-01-13 09:03:27 +00:00
|
|
|
|
$.gritter.add({
|
|
|
|
|
title: 'Failed',
|
|
|
|
|
text: 'Invalid Series Information for \'' + path + '\'',
|
|
|
|
|
image: '../../content/images/error.png',
|
|
|
|
|
class_name: 'gritter-fail'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-23 20:31:28 +00:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: addSeriesUrl,
|
2011-09-09 03:52:25 +00:00
|
|
|
|
data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId }),
|
2011-08-23 20:31:28 +00:00
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could not add " + path + " at this time. " + error);
|
|
|
|
|
},
|
|
|
|
|
success: function () {
|
|
|
|
|
root.hide('highlight', 'fast');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function reloadExistingSeries() {
|
2011-12-19 00:07:41 +00:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: existingSeriesUrl,
|
|
|
|
|
success: function( data ) {
|
2011-12-09 07:07:37 +00:00
|
|
|
|
$('#existingSeries').html(data);
|
2011-12-19 00:07:41 +00:00
|
|
|
|
}
|
2011-08-23 20:31:28 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//RootDir
|
2011-12-19 00:07:41 +00:00
|
|
|
|
//Delete RootDir
|
2011-08-23 20:31:28 +00:00
|
|
|
|
$('#rootDirs .actionButton img').live('click', function (image) {
|
|
|
|
|
var path = $(image.target).attr('id');
|
2011-12-19 00:07:41 +00:00
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: deleteRootDirUrl,
|
|
|
|
|
data: { Path: path },
|
|
|
|
|
success: function () {
|
|
|
|
|
refreshRoot();
|
|
|
|
|
$("#rootDirInput").val('');
|
|
|
|
|
}
|
2011-08-23 20:31:28 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#saveDir').live('click', saveRootDir);
|
|
|
|
|
|
|
|
|
|
function saveRootDir() {
|
|
|
|
|
var path = $("#rootDirInput").val();
|
2011-12-19 00:07:41 +00:00
|
|
|
|
|
2011-08-23 20:31:28 +00:00
|
|
|
|
if (path) {
|
2011-12-19 00:07:41 +00:00
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: saveRootDirUrl,
|
|
|
|
|
data: { Path: path },
|
|
|
|
|
success: function () {
|
|
|
|
|
refreshRoot();
|
|
|
|
|
$("#rootDirInput").val('');
|
|
|
|
|
}
|
2011-08-23 20:31:28 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function refreshRoot() {
|
2011-12-19 00:07:41 +00:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: rootListUrl,
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#rootDirs').html(data);
|
|
|
|
|
reloadAddNew();
|
|
|
|
|
reloadExistingSeries();
|
|
|
|
|
}
|
2011-08-23 20:31:28 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//AddNew
|
|
|
|
|
$('#saveNewSeries').live('click', function () {
|
|
|
|
|
var seriesTitle = $("#newSeriesLookup").val();
|
2011-09-09 03:52:25 +00:00
|
|
|
|
var seriesId = $("#newSeriesId").val();
|
2011-08-23 20:31:28 +00:00
|
|
|
|
var qualityId = $("#qualityList").val();
|
|
|
|
|
var path = $('#newSeriesPath').val();
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: addNewSeriesUrl,
|
2011-09-09 03:52:25 +00:00
|
|
|
|
data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId }),
|
2011-08-23 20:31:28 +00:00
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could not add " + path + " at this time. " + error);
|
|
|
|
|
},
|
|
|
|
|
success: function () {
|
|
|
|
|
$("#newSeriesLookup").val("");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function reloadAddNew() {
|
2011-12-19 00:07:41 +00:00
|
|
|
|
$.ajax({
|
|
|
|
|
url: addNewUrl,
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#addNewSeries').html(data);
|
|
|
|
|
}
|
2011-08-23 20:31:28 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-10-19 15:16:34 +00:00
|
|
|
|
//QuickAddNew
|
|
|
|
|
$('#quickAddNew').live('click', function () {
|
|
|
|
|
var seriesTitle = $("#newSeriesLookup").val();
|
|
|
|
|
var seriesId = $("#newSeriesId").val();
|
|
|
|
|
var qualityId = $("#qualityList").val();
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: quickAddNewSeriesUrl,
|
|
|
|
|
data: jQuery.param({ seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId }),
|
|
|
|
|
error: function (req, status, error) {
|
|
|
|
|
alert("Sorry! We could not add " + path + " at this time. " + error);
|
|
|
|
|
},
|
|
|
|
|
success: function () {
|
|
|
|
|
$("#newSeriesLookup").val("");
|
2011-12-19 00:07:41 +00:00
|
|
|
|
$('#newSeriesPath').val("");
|
2011-10-19 15:16:34 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2011-12-12 01:22:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Watermark
|
|
|
|
|
$('#rootDirInput').livequery(function () {
|
2012-01-13 09:03:27 +00:00
|
|
|
|
$(this).watermark('Enter your new root folder path...');
|
2011-12-12 01:22:10 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#newSeriesLookup').livequery(function () {
|
2012-01-13 09:03:27 +00:00
|
|
|
|
$(this).watermark('Title of the series you want to add...');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.existingSeriesContainer .seriesLookup').livequery(function () {
|
|
|
|
|
$(this).watermark('Please enter the series title...');
|
2011-12-12 01:22:10 +00:00
|
|
|
|
});
|