mirror of
https://github.com/SickGear/SickGear.git
synced 2024-11-25 06:15:04 +00:00
485 lines
39 KiB
JavaScript
485 lines
39 KiB
JavaScript
|
function toggle$(el, cond){
|
||
|
var ifId = '-if-' + $(el).attr('id');
|
||
|
if(cond){
|
||
|
$('.hide' + ifId).fadeOut('fast', 'linear');
|
||
|
$('.show' + ifId).fadeIn('fast', 'linear');
|
||
|
} else {
|
||
|
$('.show' + ifId).fadeOut('fast', 'linear');
|
||
|
$('.hide' + ifId).fadeIn('fast', 'linear');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function viewsIf(){
|
||
|
var that, className, done = [], target;
|
||
|
$('[class*="views-if"]').each(function(){
|
||
|
that = this;
|
||
|
$.each(that.classList, function(){
|
||
|
if(/views-if-/i.test(this)){
|
||
|
className = this.replace('views-if-', '');
|
||
|
if (-1 === $.inArray(className, done)){
|
||
|
done.push(className);
|
||
|
target = '[class*="show-if-' + className + '"]';
|
||
|
if ($('[class*="views-if-' + className + '"]:checked').length){
|
||
|
$(target).fadeIn('fast', 'linear');
|
||
|
} else {
|
||
|
$(target).fadeOut('fast', 'linear');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
|
||
|
$(document).ready(function () {
|
||
|
var enabler = $('.enabler'),
|
||
|
viewIf = $('input.view-if'),
|
||
|
viewIfSel = $('select.view-if');
|
||
|
|
||
|
enabler.each(function () {
|
||
|
if (!$(this).prop('checked'))
|
||
|
$(document.getElementById('content_' + $(this).attr('id'))).hide();
|
||
|
});
|
||
|
|
||
|
enabler.click(function () {
|
||
|
var content_id = $(document.getElementById('content_' + $(this).attr('id')));
|
||
|
if ($(this).prop('checked'))
|
||
|
content_id.fadeIn('fast', 'linear');
|
||
|
else
|
||
|
content_id.fadeOut('fast', 'linear');
|
||
|
});
|
||
|
|
||
|
$('[class*="views-if"]').on({click: viewsIf});
|
||
|
viewsIf();
|
||
|
|
||
|
viewIf.each(function () {
|
||
|
$(($(this).prop('checked') ? '.hide-if-' : '.show-if-') + $(this).attr('id')).hide();
|
||
|
});
|
||
|
|
||
|
viewIf.click(function () {
|
||
|
toggle$(this, $(this).prop('checked'));
|
||
|
});
|
||
|
|
||
|
viewIfSel.each(function () {
|
||
|
$((0 < $(this).find('option:selected').val() ? '.hide-if-' : '.show-if-') + $(this).attr('id')).hide();
|
||
|
});
|
||
|
|
||
|
viewIfSel.change(function(){
|
||
|
toggle$(this, 0 < $(this).find('option:selected').val());
|
||
|
});
|
||
|
|
||
|
/** @namespace data.names */
|
||
|
/** @namespace data.numbers */
|
||
|
/** @namespace data.min_remain_iv */
|
||
|
$('input#alias').on('click', function() {
|
||
|
var result$ = $('#alias-result'), that$ = $(this);
|
||
|
that$.attr('disabled', 'disabled');
|
||
|
result$.html('checking for updates...');
|
||
|
$.getJSON(sbRoot + '/config/general/update-alt',
|
||
|
function (data) {
|
||
|
var output = 'checked, ', remain;
|
||
|
result$.removeClass('grey-text');
|
||
|
if (data.names) {
|
||
|
output += 'new alias names found';
|
||
|
result$.addClass('grey-text');
|
||
|
} else if (!data.numbers) {
|
||
|
output += 'no updates found';
|
||
|
}
|
||
|
if (data.numbers) {
|
||
|
output += (data.names ? ' and ' : '') + data.numbers + ' alternative numbers updated';
|
||
|
result$.addClass('grey-text');
|
||
|
}
|
||
|
remain = data.min_remain_iv/60;
|
||
|
output += ', wait ' + parseInt(remain) + 'm before next fetch process'
|
||
|
result$.html(output);
|
||
|
that$.removeAttr('disabled');
|
||
|
});
|
||
|
});
|
||
|
|
||
|
var idSelect = '#imdb-accounts', idDel = '#imdb-list-del', idInput = '#imdb-url', idOnOff = '#imdb-list-onoff',
|
||
|
sel = 'selected', opt = 'option', selOpt = [opt, sel].join(':'),
|
||
|
elDropDown = $(idSelect), elDel = $(idDel), elInput = $(idInput), elOnOff = $(idOnOff);
|
||
|
|
||
|
function accId() {return elDropDown.find(selOpt).val();}
|
||
|
function nameList() {return elDropDown.find(selOpt).text();}
|
||
|
function isAdd() {return 'new' === accId();}
|
||
|
function isOff() {return 0 == nameList().indexOf('(Off) ');}
|
||
|
function warnMessage(msg) { elInput.addClass('warning').prop('title', msg); }
|
||
|
function all(state) {$([idSelect, idDel, idInput, idOnOff].join()).prop('disabled', 'on' == state ? !1 : !0)}
|
||
|
function setOnOff() {elOnOff.val(isAdd() || isOff() ? 'Enable' : 'Disable');}
|
||
|
function setLink() {
|
||
|
var idView = '#view-list', idLink = '#link-list';
|
||
|
return $([idView, idLink].join()).removeClass() &&
|
||
|
((isAdd() || isOff()) && $(idLink).addClass('hide') || $(idView).addClass('hide')) &&
|
||
|
(!isOff() && $(idLink)
|
||
|
.attr('href', sbRoot + '/add-shows/watchlist-imdb?account=' + accId())
|
||
|
.attr('title', 'View ' + nameList()));
|
||
|
}
|
||
|
|
||
|
function defaultControls() {
|
||
|
elDel.prop('disabled', isAdd());
|
||
|
elInput.removeClass('warning')
|
||
|
.val(!isAdd() && accId() || '')
|
||
|
.prop('title', isAdd() ? '' : 'Select Add. Use Delete or Disable')
|
||
|
.prop('readonly', !isAdd());
|
||
|
setOnOff();
|
||
|
setLink();
|
||
|
}
|
||
|
|
||
|
function populateSelect(jsonData) {
|
||
|
/** @namespace response.accounts */
|
||
|
var response = $.parseJSON(jsonData);
|
||
|
|
||
|
if ('Success' !== response.result) {
|
||
|
warnMessage(response.result);
|
||
|
return !1;
|
||
|
}
|
||
|
|
||
|
elDropDown.find(opt).slice(1).remove();
|
||
|
var i, l, accounts = response.accounts, options = elDropDown.get(0).options;
|
||
|
for (i = 0, l = accounts.length; i < l; i = i + 2) {
|
||
|
options[options.length] = new Option(accounts[i + 1] +
|
||
|
(0 == accounts[i + 1].replace('(Off) ', '').toLowerCase().indexOf('your') ? '' : '\'s') + ' list', accounts[i]);
|
||
|
if (0 <= $.trim(elInput.val()).indexOf(accounts[i])) {
|
||
|
elDropDown.find(opt).prop(sel, !1);
|
||
|
elDropDown.find('option[value="' + accounts[i] + '"]').prop(sel, sel);
|
||
|
elInput.val(accounts[i]);
|
||
|
elInput.prop('title', 'Select Add. Use Delete or Disable');
|
||
|
setOnOff();
|
||
|
}
|
||
|
}
|
||
|
return !0;
|
||
|
}
|
||
|
|
||
|
elDropDown.change(function() {
|
||
|
defaultControls();
|
||
|
});
|
||
|
|
||
|
elDel.on('click', function(e) {
|
||
|
all('off');
|
||
|
$.confirm({
|
||
|
'title' : 'Remove the "' + nameList().replace('\'s', '').replace(' list', '') + '" IMDb Watchlist',
|
||
|
'message' : 'Are you sure you want to remove <span class="footerhighlight">' + nameList() + '</span> ?<br /><br />',
|
||
|
'buttons' : {
|
||
|
'Yes' : {
|
||
|
'class' : 'green',
|
||
|
'action': function() {
|
||
|
all('off');
|
||
|
$.get(sbRoot + '/add-shows/watchlist-imdb', {
|
||
|
'action': elDel.val().toLowerCase(),
|
||
|
'select': accId()})
|
||
|
.done(function(response) {
|
||
|
all('on'); setControls(!populateSelect(response), !1); setOnOff(); })
|
||
|
.fail(function() {
|
||
|
all('on'); setControls(!0, 'Invalid ID'); setOnOff(); });
|
||
|
}
|
||
|
},
|
||
|
'No' : {
|
||
|
'class' : 'red',
|
||
|
'action': function() { e.preventDefault(); all('on'); defaultControls();}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
elOnOff.on('click', function(e) {
|
||
|
var strList = $.trim(elInput.val());
|
||
|
|
||
|
elInput.removeClass('warning');
|
||
|
if (!strList) {
|
||
|
warnMessage('Missing IMDb list Id or URL');
|
||
|
} else {
|
||
|
all('off');
|
||
|
var params = {'action': elOnOff.val().toLowerCase()};
|
||
|
if ('enable' == params.action)
|
||
|
params.input = strList;
|
||
|
else
|
||
|
params.select = accId();
|
||
|
|
||
|
$.get(sbRoot + '/add-shows/watchlist-imdb', params)
|
||
|
.done(function(data) { setControls(!populateSelect(data), !1); })
|
||
|
.fail(function() { setControls(!0, 'Failed to load list'); });
|
||
|
}
|
||
|
});
|
||
|
|
||
|
function setControls(resetSelect, message) {
|
||
|
all('on');
|
||
|
if (resetSelect) {
|
||
|
if (message)
|
||
|
warnMessage(message);
|
||
|
var addList = '[value="new"]';
|
||
|
elDropDown.find(opt).not(addList).prop(sel, !1);
|
||
|
elDropDown.find(opt + addList).prop(sel, sel);
|
||
|
}
|
||
|
elDel.prop('disabled', isAdd());
|
||
|
elInput.prop('readonly', !isAdd());
|
||
|
setLink()
|
||
|
}
|
||
|
|
||
|
var ui_update_trim_zero = (function () {
|
||
|
var secs = ('00' + new Date().getSeconds().toString()).slice(-2),
|
||
|
elSecs = $('#trim_info_seconds'),
|
||
|
elTrimZero = $('#trim_zero');
|
||
|
elTrimZero.each(function () {
|
||
|
var checked = $(this).prop('checked') && $('#fuzzy_dating').prop('checked');
|
||
|
|
||
|
$('#time_presets').find('option').each(function () {
|
||
|
var text = ($(this).text());
|
||
|
$(this).text(checked
|
||
|
? text.replace(/(\b\d+:\d\d):\d+/mg, '$1')
|
||
|
: text.replace(/(\b\d+:\d\d)(?:.\d+)?/mg, '$1:' + secs));
|
||
|
});
|
||
|
});
|
||
|
|
||
|
if ($('#fuzzy_dating').prop('checked'))
|
||
|
if (elTrimZero.prop('checked'))
|
||
|
elSecs.fadeOut('fast', 'linear');
|
||
|
else
|
||
|
elSecs.fadeIn('fast', 'linear');
|
||
|
else
|
||
|
elSecs.fadeIn('fast', 'linear');
|
||
|
});
|
||
|
|
||
|
$('#trim_zero, #fuzzy_dating').click(function () {
|
||
|
ui_update_trim_zero();
|
||
|
});
|
||
|
|
||
|
ui_update_trim_zero();
|
||
|
|
||
|
$('.datePresets').click(function () {
|
||
|
var elDatePresets = $('#date_presets'),
|
||
|
defaultPreset = elDatePresets.val();
|
||
|
if ($(this).prop('checked') && '%x' == defaultPreset) {
|
||
|
defaultPreset = '%a, %b %d, %Y';
|
||
|
$('#date_use_system_default').html('1')
|
||
|
} else if (!$(this).prop('checked') && '1' == $('#date_use_system_default').html())
|
||
|
defaultPreset = '%x';
|
||
|
|
||
|
elDatePresets.attr('name', 'date_preset_old');
|
||
|
elDatePresets.attr('id', 'date_presets_old');
|
||
|
|
||
|
var elDatePresets_na = $('#date_presets_na');
|
||
|
elDatePresets_na.attr('name', 'date_preset');
|
||
|
elDatePresets_na.attr('id', 'date_presets');
|
||
|
|
||
|
var elDatePresets_old = $('#date_presets_old');
|
||
|
elDatePresets_old.attr('name', 'date_preset_na');
|
||
|
elDatePresets_old.attr('id', 'date_presets_na');
|
||
|
|
||
|
if (defaultPreset)
|
||
|
elDatePresets.val(defaultPreset)
|
||
|
});
|
||
|
|
||
|
// bind 'myForm' and provide a simple callback function
|
||
|
$('#configForm').ajaxForm({
|
||
|
beforeSubmit: function () {
|
||
|
$('.config_submitter').each(function () {
|
||
|
$(this).attr('disabled', 'disabled');
|
||
|
$(this).after('<span><img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif"> Saving...</span>');
|
||
|
$(this).hide();
|
||
|
});
|
||
|
$('.show_update_hour_value').text($('#show_update_hour').val())
|
||
|
},
|
||
|
success: function (response) {
|
||
|
setTimeout(function () {config_success(response)}, 2000);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var updateFB = function(){
|
||
|
$('a[rel=qr]').fancybox({
|
||
|
smallBtn: !0,
|
||
|
type:'inline',
|
||
|
baseClass: 'apikey-qr-dlg',
|
||
|
afterLoad: function() {
|
||
|
$('#qr-body')
|
||
|
.html('')
|
||
|
.qrcode({
|
||
|
render: 'image', fill: '#333', radius: 0.5, minVersion: 6,
|
||
|
background: null, size: 300, text: this.opts.apiKey })
|
||
|
.append('<div class="qr-title"><em>App name:</em> <span>' + this.opts.apiName + '</span></div>');
|
||
|
},
|
||
|
});
|
||
|
};
|
||
|
var addQR = function(){
|
||
|
if (!!$('a[rel=qr]').length){
|
||
|
if ('function' === typeof($.fn.fancybox)){
|
||
|
updateFB();
|
||
|
} else {
|
||
|
var fancy = sbRoot + '/js/fancybox/jquery.fancybox.min';
|
||
|
$.getScript(fancy + '.js', function () {
|
||
|
$('head').append('<link rel="stylesheet" href="' + fancy + '.css">');
|
||
|
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("jquery-qrcode",[],r):"object"==typeof exports?exports["jquery-qrcode"]=r():t["jquery-qrcode"]=r()}("undefined"!=typeof self?self:this,function(){return function(e){var n={};function o(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=e,o.c=n,o.d=function(t,r,e){o.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(r,t){if(1&t&&(r=o(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var e=Object.create(null);if(o.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var n in r)o.d(e,n,function(t){return r[t]}.bind(null,n));return e},o.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(r,"a",r),r},o.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},o.p="",o(o.s=0)}([function(v,t,p){(function(t){function c(t){return t&&"string"==typeof t.tagName&&"IMG"===t.tagName.toUpperCase()}function a(t,r,e,n){var o={},i=p(2);i.stringToBytes=i.stringToBytesFuncs["UTF-8"];var a=i(e,r);a.addData(t),a.make(),n=n||0;var u=a.getModuleCount(),s=u+2*n;return o.text=t,o.level=r,o.version=e,o.module_count=s,o.is_dark=function(t,r){return r-=n,0<=(t-=n)&&t<u&&0<=r&&r<u&&a.isDark(t,r)},o.add_blank=function(a,u,f,c){var l=o.is_dark,g=1/s;o.is_dark=function(t,r){var e=r*g,n=t*g,o=e+g,i=n+g;return l(t,r)&&(o<a||f<e||i<u||c<n)}},o}function h(t,r,e,n,o){e=Math.max(1,e||1),n=Math.min(40,n||40);for(var i=e;i<=n;i+=1)try{return a(t,r,i,o)}catch(t){}}function i(t,r,e){c(e.background)?r.drawImage(e.background,0,0,e.size,e.size):e.background&&(r.fillStyle=e.background,r.fillRect(e.left,e.top,e.size,e.size));var n=e.mode;1===n||2===n?function(t,r,e){var n=e.size,o="bold "+e.mSize*n+"px "+e.fontname,i=d("<canvas/>")[0].getContext("2d");i.font=o;var a=i.measureText(e.label).width,u=e.mSize,f=a/n,c=(1-f)*e.mPosX,l=(1-u)*e.mPosY,g=c+f,s=l+u;1===e.mode?t.add_blank(0,l-.01,n,s+.01):t.add_blank(c-.01,l-.01,.01+g,s+.01),r.fillStyle=e.fontcolor,r.font=o,r.fillText(e.label,c*n,l*n+.75*e.mSize*n)}(t,r,e):!c(e.image)||3!==n&&4!==n||function(t,r,e){var n=e.size,o=e.image.naturalWidth||1,i=e.image.naturalHeight||1,a=e.mSize,u=a*o/i,f=(1-u)*e.mPosX,c=(1-a)*e.mPosY,l=f+u,g=c+a;3===e.mode?t.add_blank(0,c-.01,n,g+.01):t.add_blank(f-.01,c-.01,.01+l,g+.01),r.drawImage(e.image,f*n,c*n,u*n,a*n)}(t,r,e)}function l(t,r,e,n,o,i,a,u){t.is_dark(a,u)&&r.rect(n,o,i,i)}function g(t,r,e,n,o,i,a,u){var f=t.is_dark,c=n+i,l=o+i,g=e.radius*i,s=a-1,h=a+1,d=u-1,v=u+1,p=f(a,u),w=f(s,d),y=f(s,u),m=f(s,v),b=f(a,v),k=f(h,v),C=f(h,u),B=f(h,d),x=f(a,d);p?function(t,r,e,n,o,i,a,u,f,c){a?t.moveTo(r+i,e):t.moveTo(r,e),u?(t.lineTo(n-i,e),t.arcTo(n,e,n,o,i)):t.lineTo(n,e),f?(t.lineTo(n,o-i),t.arcTo(n,o,r,o,i)):t.lineTo(n,o),c?(t.lineTo(r+i,o),t.arcTo(r,o,r,e,i)):t.lineTo(r,o),a?(t.lineTo(r,e+i),t.arcTo(r,e,n,e,i)):t.lineTo(r,e)}(r,n,o,c,l,g,!y&&!x,!y&&!b,!C&&!b,!C&&!x):function(t,r,e,n,o,i,a,u,f,c){a&&(t.moveTo(r+i,e),t.lineTo(r,e),t.lineTo(r,e+i),t.arcTo(r,e,r+i,e,i)),u&&(t.moveTo(n-i,e),t.lineTo(n,e),t.lineTo(n,e+i),t.arcTo(n,e,n-i,e,i)),f&&(t.moveTo(n-i,o),t.lineTo(n,o),t.lineTo(n,o-i),t.arcTo(n,o,n-i,o,i)),c&&(t.moveTo(r+i,o),t.lineTo(r,o),t.lineTo(r,o-i),t.arcTo(r,o,r+i,o,i))}(r,n,o,c,l,g,y&&x&&w,y&&b&&m,C&&b&&k,C&&x&&B)}function n(t,r){var e=h(r.text,r.ecLevel,r.minVersion,r.maxVersion,r.quiet);if(!e)return null;var n=d(t).data("qrcode",e),o=n[0].getContext("2d");return i(e,o,r),function(t,r,e){var n,o,i=t.module_count,a=e.size/i,u=l;for(0<e.radius&&e.radius<=.5&&(u=g),r.beginPath(),n=0;n<i;n+=1)for(o=0;o<i;o+=1)u(t,r,e,e.left+o*a,e.top+n*a,a,n,o);if(c(e.fill)){r.strokeStyle="rgba(0,0,0,0.5)",r.lineWidth=2,r.stroke();var f=r.globalCompositeOperation;r.globalCompositeOperation="
|
||
|
updateFB();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
addQR();
|
||
|
var generateApiKey = function(){
|
||
|
var appName$ = $('#app-name');
|
||
|
appName$.removeClass('warning');
|
||
|
$('#generate-result').html(' ').removeClass('dotted-surround');
|
||
|
$.getJSON(sbRoot + '/config/general/create_apikey', {app_name: appName$.val()},
|
||
|
function (data) {
|
||
|
if (undefined === data.error) {
|
||
|
var appInput$ = $('#app-name');
|
||
|
if (undefined === data.added) {
|
||
|
appInput$.addClass('warning');
|
||
|
$('#generate-result').html(data.result).addClass('dotted-surround');
|
||
|
} else {
|
||
|
$('#tip-addkeys').hide();
|
||
|
var newRow$ = $('#api-keys')
|
||
|
.append($('.new-key').first().clone(!0))
|
||
|
.find('.new-key').last().removeClass('new-key');
|
||
|
newRow$.find('.api-key').text(data.added);
|
||
|
newRow$.find('.app-name').text(appInput$.val());
|
||
|
newRow$.find('a')
|
||
|
.attr('rel', 'qr')
|
||
|
.attr('data-api-key', data.added)
|
||
|
.attr('data-api-name', appInput$.val());
|
||
|
appInput$.val('');
|
||
|
newRow$.show();
|
||
|
addQR();
|
||
|
}
|
||
|
} else {
|
||
|
alert(data.error);
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
$('#app-name').keypress(function(ev){
|
||
|
if (13 === ev.which) {
|
||
|
ev.preventDefault();
|
||
|
generateApiKey();
|
||
|
return !1;
|
||
|
}
|
||
|
});
|
||
|
$('#generate-api-key').on('click', generateApiKey);
|
||
|
$('.revoke').on('click', function(){
|
||
|
$('#app-name').removeClass('warning');
|
||
|
$('#generate-result').html(' ').removeClass('dotted-surround');
|
||
|
var row$ = $(this).closest('div'), appName = row$.find('.app-name').text();
|
||
|
if (confirm('Revoke "' + appName + '" apikey?')) {
|
||
|
$.getJSON(sbRoot + '/config/general/revoke_apikey', {
|
||
|
app_name: appName,
|
||
|
api_key: row$.find('.api-key').text()},
|
||
|
function (data) {
|
||
|
if (undefined === data.error) {
|
||
|
if (undefined === data.removed) {
|
||
|
$('#app-name').addClass('warning');
|
||
|
$('#generate-result').html(data.result).addClass('dotted-surround');
|
||
|
} else {
|
||
|
row$.remove();
|
||
|
if (!$('#api-keys').find('div:visible').length) {
|
||
|
$('#tip-addkeys').show();
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
alert(data.error);
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
$('#branch-checkout').click(function () {
|
||
|
window.location.href = sbRoot + '/home/branch-checkout?branch=' + $('#branchVersion').val();
|
||
|
});
|
||
|
|
||
|
$('#pull-request-checkout').click(function () {
|
||
|
window.location.href = sbRoot + '/home/pull-request-checkout?branch=' + $('#pullRequestVersion').val();
|
||
|
});
|
||
|
|
||
|
fetch_branches();
|
||
|
fetch_pullrequests();
|
||
|
|
||
|
$('#showlist_tagview').on('change', function() {
|
||
|
var selected = '#showlist_tagview_', target = $(selected + 'custom_config');
|
||
|
target.removeClass('hidden');
|
||
|
if ('custom' !== $(this).val())
|
||
|
target.addClass('hidden');
|
||
|
$(selected + 'standard,' + selected + 'anime,' + selected + 'custom').removeClass('hidden').addClass('hidden');
|
||
|
$(selected + $(this).val()).removeClass('hidden');
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function config_success(response) {
|
||
|
if ('reload' == response) {
|
||
|
window.location.reload(true);
|
||
|
} else if ('restart' == response) {
|
||
|
window.location.href = sbRoot + $('a.restart').attr('href')
|
||
|
}
|
||
|
$('.config_submitter').each(function () {
|
||
|
$(this).removeAttr('disabled');
|
||
|
$(this).next().remove();
|
||
|
$(this).show();
|
||
|
});
|
||
|
$('#email_show').trigger('notify');
|
||
|
|
||
|
// update footer only on the config page for the propers option
|
||
|
if('saveSearch' == $('#configForm').attr('action')){
|
||
|
getFooterTime({'change_layout': 0});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function fetch_pullrequests() {
|
||
|
$.getJSON(sbRoot + '/config/general/fetch-pullrequests', function (data) {
|
||
|
$('#pullRequestVersion').find('option').remove();
|
||
|
if (data['result'] == 'success') {
|
||
|
var pulls = [];
|
||
|
$.each(data['pulls'], function (i, pull) {
|
||
|
if (pull[0] != '') {
|
||
|
pulls.push(pull);
|
||
|
}
|
||
|
});
|
||
|
if (pulls.length > 0) {
|
||
|
$.each(pulls, function (i, text) {
|
||
|
add_option_to_pulls(text);
|
||
|
});
|
||
|
$('#pull-request-checkout').removeAttr('disabled');
|
||
|
} else {
|
||
|
add_option_to_pulls(['No pull requests available', '']);
|
||
|
}
|
||
|
} else {
|
||
|
add_option_to_pulls(['Failed to connect to github', '']);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function fetch_branches() {
|
||
|
$.getJSON(sbRoot + '/config/general/fetch-branches', function (data) {
|
||
|
$('#branchVersion').find('option').remove();
|
||
|
if (data['result'] == 'success') {
|
||
|
var branches = [];
|
||
|
$.each(data['branches'], function (i, branch) {
|
||
|
if (branch != '') {
|
||
|
branches.push(branch);
|
||
|
}
|
||
|
});
|
||
|
if (branches.length > 0) {
|
||
|
$.each(branches, function (i, text) {
|
||
|
add_option_to_branches(text);
|
||
|
});
|
||
|
$('#branch-checkout').removeAttr('disabled');
|
||
|
$('#branchVersion').find('option[value="' + data['current'] + '"]').prop('selected', !0);
|
||
|
} else {
|
||
|
add_option_to_branches('No branches available');
|
||
|
}
|
||
|
} else {
|
||
|
add_option_to_branches('Failed to connect to github');
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function add_option_to_pulls(text) {
|
||
|
var option = $('<option>');
|
||
|
option.val(text[1]);
|
||
|
option.html(text[0]);
|
||
|
option.appendTo('#pullRequestVersion');
|
||
|
}
|
||
|
|
||
|
function add_option_to_branches(text) {
|
||
|
var option = $('<option>');
|
||
|
option.val(text);
|
||
|
option.html(text);
|
||
|
option.appendTo('#branchVersion');
|
||
|
}
|