SickGear/gui/slick/js/massUpdate.js

114 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-10-17 18:08:14 +00:00
/** @namespace $.SickGear.Root */
$(document).ready(function() {
$('#submitMassEdit').click(function() {
var editArr = [];
$('.editCheck').each(function() {
if (true == this.checked) {
editArr.push($(this).attr('id').split('-')[1])
}
});
if (0 == editArr.length)
return !1;
window.location.href = $.SickGear.Root + '/manage/massEdit?toEdit=' + editArr.join('|');
2014-09-30 22:20:37 +00:00
});
2016-10-17 18:08:14 +00:00
$('#submitMassUpdate').click(function() {
var updateArr = [], refreshArr = [], renameArr = [], subtitleArr = [],
deleteArr = [], removeArr = [], metadataArr = [];
$('.updateCheck').each(function() {
if (true == this.checked) {
updateArr.push($(this).attr('id').split('-')[1])
}
});
$('.refreshCheck').each(function() {
if (true == this.checked) {
refreshArr.push($(this).attr('id').split('-')[1])
}
});
$('.renameCheck').each(function() {
if (true == this.checked) {
renameArr.push($(this).attr('id').split('-')[1])
}
});
$('.subtitleCheck').each(function() {
if (true == this.checked) {
subtitleArr.push($(this).attr('id').split('-')[1])
}
});
$('.deleteCheck').each(function() {
if (true == this.checked) {
deleteArr.push($(this).attr('id').split('-')[1])
}
});
$('.removeCheck').each(function() {
if (true == this.checked) {
removeArr.push($(this).attr('id').split('-')[1])
}
});
/*
2016-10-17 18:08:14 +00:00
$('.metadataCheck').each(function() {
if (true == this.checked) {
metadataArr.push($(this).attr('id').split('-')[1])
}
});
*/
2016-10-17 18:08:14 +00:00
if (0 == updateArr.length + refreshArr.length + renameArr.length + subtitleArr.length + deleteArr.length + removeArr.length + metadataArr.length)
return !1;
2016-10-17 18:08:14 +00:00
window.location.href = $.SickGear.Root + 'massUpdate?toUpdate=' + updateArr.join('|') + '&toRefresh=' + refreshArr.join('|') + '&toRename=' + renameArr.join('|') + '&toSubtitle=' + subtitleArr.join('|') + '&toDelete=' + deleteArr.join('|') + '&toRemove=' + removeArr.join('|') + '&toMetadata=' + metadataArr.join('|');
2016-10-17 18:08:14 +00:00
});
2016-10-17 18:08:14 +00:00
$('.bulkCheck').click(function() {
2016-10-17 18:08:14 +00:00
var bulkCheck = this, whichBulkCheck = $(bulkCheck).attr('id');
2016-10-17 18:08:14 +00:00
$('.' + whichBulkCheck).each(function() {
if (!this.disabled)
this.checked = !this.checked
});
});
2016-10-17 18:08:14 +00:00
['.editCheck', '.updateCheck', '.refreshCheck', '.renameCheck', '.deleteCheck', '.removeCheck'].forEach(function(name) {
var lastCheck = null;
2016-10-17 18:08:14 +00:00
$(name).click(function(event) {
2016-10-17 18:08:14 +00:00
if(!lastCheck || !event.shiftKey) {
lastCheck = this;
return;
}
2016-10-17 18:08:14 +00:00
var check = this, found = 0;
2016-10-17 18:08:14 +00:00
$(name).each(function() {
switch (found) {
case 2:
return !1;
case 1:
if (!this.disabled)
this.checked = lastCheck.checked;
}
2016-10-17 18:08:14 +00:00
if (this == check || this == lastCheck)
found++;
});
});
});
});