2014-03-10 01:18:05 -04:00
|
|
|
$(document).ready(function(){
|
|
|
|
|
|
|
|
$('#sbRoot').ajaxEpSearch({'colorRow': true});
|
|
|
|
$('#sbRoot').ajaxEpRetry({'colorRow': true});
|
|
|
|
|
|
|
|
$('#sbRoot').ajaxEpSubtitlesSearch();
|
|
|
|
|
|
|
|
$('#seasonJump').change(function() {
|
|
|
|
var id = $(this).val();
|
|
|
|
if (id && id != 'jump') {
|
|
|
|
$('html,body').animate({scrollTop: $(id).offset().top},'slow');
|
|
|
|
location.hash = id;
|
|
|
|
}
|
|
|
|
$(this).val('jump');
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#prevShow").click(function(){
|
|
|
|
$('#pickShow option:selected').prev('option').attr('selected', 'selected');
|
|
|
|
$("#pickShow").change();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#nextShow").click(function(){
|
|
|
|
$('#pickShow option:selected').next('option').attr('selected', 'selected');
|
|
|
|
$("#pickShow").change();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#changeStatus').click(function(){
|
2014-03-20 14:03:22 -04:00
|
|
|
var sbRoot = $('#sbRoot').val()
|
|
|
|
var epArr = new Array()
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
$('.epCheck').each(function() {
|
|
|
|
|
|
|
|
if (this.checked == true) {
|
|
|
|
epArr.push($(this).attr('id'))
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (epArr.length == 0)
|
2014-03-20 14:03:22 -04:00
|
|
|
return false
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-03-20 14:03:22 -04:00
|
|
|
url = sbRoot+'/home/setStatus?show='+$('#showID').attr('value')+'&eps='+epArr.join('|')+'&status='+$('#statusSelect').attr('value')
|
2014-03-10 01:18:05 -04:00
|
|
|
window.location.href = url
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.seasonCheck').click(function(){
|
|
|
|
var seasCheck = this;
|
|
|
|
var seasNo = $(seasCheck).attr('id');
|
|
|
|
|
|
|
|
$('.epCheck:visible').each(function(){
|
2014-03-20 14:03:22 -04:00
|
|
|
var epParts = $(this).attr('id').split('x')
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
if (epParts[0] == seasNo) {
|
|
|
|
this.checked = seasCheck.checked
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var lastCheck = null;
|
|
|
|
$('.epCheck').click(function(event) {
|
|
|
|
|
|
|
|
if(!lastCheck || !event.shiftKey) {
|
|
|
|
lastCheck = this;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var check = this;
|
|
|
|
var found = 0;
|
|
|
|
|
|
|
|
$('.epCheck').each(function() {
|
|
|
|
switch (found) {
|
|
|
|
case 2: return false;
|
|
|
|
case 1: this.checked = lastCheck.checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this == check || this == lastCheck)
|
|
|
|
found++;
|
|
|
|
});
|
|
|
|
|
|
|
|
lastClick = this;
|
|
|
|
});
|
|
|
|
|
|
|
|
// selects all visible episode checkboxes.
|
|
|
|
$('.seriesCheck').click(function(){
|
|
|
|
$('.epCheck:visible').each(function(){
|
|
|
|
this.checked = true
|
|
|
|
});
|
|
|
|
$('.seasonCheck:visible').each(function(){
|
|
|
|
this.checked = true
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
// clears all visible episode checkboxes and the season selectors
|
|
|
|
$('.clearAll').click(function(){
|
|
|
|
$('.epCheck:visible').each(function(){
|
|
|
|
this.checked = false
|
|
|
|
});
|
|
|
|
$('.seasonCheck:visible').each(function(){
|
|
|
|
this.checked = false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// handle the show selection dropbox
|
|
|
|
$('#pickShow').change(function(){
|
2014-03-20 14:03:22 -04:00
|
|
|
var sbRoot = $('#sbRoot').val()
|
|
|
|
var val = $(this).attr('value')
|
2014-03-10 01:18:05 -04:00
|
|
|
if (val == 0)
|
2014-03-20 14:03:22 -04:00
|
|
|
return
|
|
|
|
url = sbRoot+'/home/displayShow?show='+val
|
2014-03-10 01:18:05 -04:00
|
|
|
window.location.href = url
|
|
|
|
});
|
|
|
|
|
|
|
|
// show/hide different types of rows when the checkboxes are changed
|
|
|
|
$("#checkboxControls input").change(function(e){
|
2014-03-20 14:03:22 -04:00
|
|
|
var whichClass = $(this).attr('id')
|
|
|
|
$(this).showHideRows(whichClass)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
$('tr.'+whichClass).each(function(i){
|
|
|
|
$(this).toggle();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// initially show/hide all the rows according to the checkboxes
|
|
|
|
$("#checkboxControls input").each(function(e){
|
|
|
|
var status = this.checked;
|
|
|
|
$("tr."+$(this).attr('id')).each(function(e){
|
|
|
|
if (status) {
|
|
|
|
$(this).show();
|
|
|
|
} else {
|
|
|
|
$(this).hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-03-20 14:03:22 -04:00
|
|
|
$.fn.showHideRows = function(whichClass){
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-03-20 14:03:22 -04:00
|
|
|
var status = $('#checkboxControls > input, #'+whichClass).prop('checked')
|
|
|
|
$("tr."+whichClass).each(function(e){
|
2014-03-10 01:18:05 -04:00
|
|
|
if (status) {
|
|
|
|
$(this).show();
|
|
|
|
} else {
|
|
|
|
$(this).hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// hide season headers with no episodes under them
|
2014-03-20 14:03:22 -04:00
|
|
|
$('tr.seasonheader').each(function(){
|
|
|
|
var numRows = 0
|
|
|
|
var seasonNo = $(this).attr('id')
|
|
|
|
$('tr.'+seasonNo+' :visible').each(function(){
|
2014-03-10 01:18:05 -04:00
|
|
|
numRows++
|
2014-03-20 14:03:22 -04:00
|
|
|
})
|
2014-03-10 01:18:05 -04:00
|
|
|
if (numRows == 0) {
|
2014-03-20 14:03:22 -04:00
|
|
|
$(this).hide()
|
|
|
|
$('#'+seasonNo+'-cols').hide()
|
2014-03-10 01:18:05 -04:00
|
|
|
} else {
|
2014-03-20 14:03:22 -04:00
|
|
|
$(this).show()
|
|
|
|
$('#'+seasonNo+'-cols').show()
|
2014-03-10 01:18:05 -04:00
|
|
|
}
|
|
|
|
|
2014-03-20 14:03:22 -04:00
|
|
|
});
|
|
|
|
}
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
function setEpisodeSceneNumbering(forSeason, forEpisode, sceneSeason, sceneEpisode) {
|
|
|
|
var sbRoot = $('#sbRoot').val();
|
|
|
|
var showId = $('#showID').val();
|
|
|
|
|
|
|
|
if (sceneSeason === '') sceneSeason = null;
|
|
|
|
if (sceneEpisode === '') sceneEpisode = null;
|
|
|
|
|
|
|
|
$.getJSON(sbRoot + '/home/setEpisodeSceneNumbering',
|
|
|
|
{
|
|
|
|
'show': showId,
|
|
|
|
'forSeason': forSeason,
|
|
|
|
'forEpisode': forEpisode,
|
|
|
|
'sceneSeason': sceneSeason,
|
|
|
|
'sceneEpisode': sceneEpisode
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
// Set the values we get back
|
|
|
|
if (data.sceneSeason === null || data.sceneEpisode === null)
|
|
|
|
{
|
|
|
|
$('#sceneSeasonXEpisode_' + showId + '_' + forSeason +'_' + forEpisode).val('');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#sceneSeasonXEpisode_' + showId + '_' + forSeason +'_' + forEpisode).val(data.sceneSeason + 'x' + data.sceneEpisode);
|
|
|
|
}
|
|
|
|
if (!data.success)
|
|
|
|
{
|
|
|
|
if (data.errorMessage) {
|
|
|
|
alert(data.errorMessage);
|
|
|
|
} else {
|
|
|
|
alert('Update failed.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.sceneSeasonXEpisode').change(function() {
|
|
|
|
// Strip non-numeric characters
|
|
|
|
$(this).val($(this).val().replace(/[^0-9xX]*/g,''));
|
|
|
|
var forSeason = $(this).attr('data-for-season');
|
|
|
|
var forEpisode = $(this).attr('data-for-episode');
|
|
|
|
var showId = $('#showID').val();
|
|
|
|
|
|
|
|
//var sceneEpisode = $('#sceneEpisode_' + showId + '_' + forSeason +'_' + forEpisode).val();
|
|
|
|
var m = $(this).val().match(/^(\d+)x(\d+)$/i);
|
|
|
|
var sceneSeason = null, sceneEpisode = null;
|
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
sceneSeason = m[1];
|
|
|
|
sceneEpisode = m[2];
|
|
|
|
}
|
|
|
|
setEpisodeSceneNumbering(forSeason, forEpisode, sceneSeason, sceneEpisode);
|
|
|
|
});
|
|
|
|
});
|