2015-03-02 11:31:11 +00:00
|
|
|
$(document).ready(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
var enabler = $('.enabler'),
|
|
|
|
viewIf = $('.viewIf');
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
enabler.each(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
if (!$(this).prop('checked'))
|
|
|
|
$('#content_' + $(this).attr('id')).hide();
|
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
enabler.click(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
var content_id = $('#content_' + $(this).attr('id'));
|
|
|
|
if ($(this).prop('checked'))
|
|
|
|
content_id.fadeIn('fast', 'linear');
|
|
|
|
else
|
|
|
|
content_id.fadeOut('fast', 'linear');
|
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
viewIf.each(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
$(($(this).prop('checked') ? '.hide_if_' : '.show_if_') + $(this).attr('id')).hide();
|
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
viewIf.click(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
var if_id = '_if_' + $(this).attr('id');
|
|
|
|
if ($(this).prop('checked')) {
|
|
|
|
$('.hide' + if_id).fadeOut('fast', 'linear');
|
|
|
|
$('.show' + if_id).fadeIn('fast', 'linear');
|
|
|
|
} else {
|
|
|
|
$('.show' + if_id).fadeOut('fast', 'linear');
|
|
|
|
$('.hide' + if_id).fadeIn('fast', 'linear');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
var ui_update_trim_zero = (function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
var secs = ('00' + new Date().getSeconds().toString()).slice(-2),
|
|
|
|
elSecs = $('#trim_info_seconds'),
|
|
|
|
elTrimZero = $('#trim_zero');
|
2015-03-02 11:31:11 +00:00
|
|
|
elTrimZero.each(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
var checked = $(this).prop('checked') && $('#fuzzy_dating').prop('checked');
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
$('#time_presets').find('option').each(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
$('#trim_zero, #fuzzy_dating').click(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
ui_update_trim_zero();
|
|
|
|
});
|
|
|
|
|
|
|
|
ui_update_trim_zero();
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
$('.datePresets').click(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
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({
|
2015-03-02 11:31:11 +00:00
|
|
|
beforeSubmit: function () {
|
|
|
|
$('.config_submitter').each(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
$(this).attr('disabled', 'disabled');
|
|
|
|
$(this).after('<span><img src="' + sbRoot + '/images/loading16' + themeSpinner + '.gif"> Saving...</span>');
|
|
|
|
$(this).hide();
|
|
|
|
});
|
2015-02-15 14:54:08 +00:00
|
|
|
$('.show_update_hour_value').text($('#show_update_hour').val())
|
2014-12-17 18:25:23 +00:00
|
|
|
},
|
2015-03-02 11:31:11 +00:00
|
|
|
success: function (response) {
|
|
|
|
setTimeout(function () {config_success(response)}, 2000);
|
2014-12-17 18:25:23 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
$('#api_key').click(function () {$('#api_key').select()});
|
|
|
|
$('#generate_new_apikey').click(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
$.get(sbRoot + '/config/general/generateKey',
|
2015-03-02 11:31:11 +00:00
|
|
|
function (data) {
|
2014-12-17 18:25:23 +00:00
|
|
|
if (data.error != undefined) {
|
|
|
|
alert(data.error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#api_key').val(data);
|
2015-03-02 11:31:11 +00:00
|
|
|
});
|
2014-12-17 18:25:23 +00:00
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
$('#branchCheckout').click(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
window.location.href = sbRoot + '/home/branchCheckout?branch=' + $('#branchVersion').val();
|
|
|
|
});
|
2014-12-29 04:22:34 +00:00
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
$('#pullRequestCheckout').click(function () {
|
2014-12-29 04:22:34 +00:00
|
|
|
window.location.href = sbRoot + '/home/pullRequestCheckout?branch=' + $('#pullRequestVersion').val();
|
|
|
|
});
|
2015-03-02 11:31:11 +00:00
|
|
|
|
|
|
|
fetch_branches();
|
|
|
|
fetch_pullrequests();
|
2015-05-03 00:42:14 +00:00
|
|
|
|
|
|
|
$('#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');
|
|
|
|
});
|
2014-03-10 05:18:05 +00:00
|
|
|
});
|
|
|
|
|
2015-03-02 11:31:11 +00:00
|
|
|
function config_success(response) {
|
|
|
|
if (response == 'reload') {
|
2015-02-26 02:04:55 +00:00
|
|
|
window.location.reload(true);
|
|
|
|
}
|
2015-03-02 11:31:11 +00:00
|
|
|
$('.config_submitter').each(function () {
|
2014-12-17 18:25:23 +00:00
|
|
|
$(this).removeAttr('disabled');
|
|
|
|
$(this).next().remove();
|
|
|
|
$(this).show();
|
|
|
|
});
|
|
|
|
$('#email_show').trigger('notify');
|
2015-03-02 11:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
$('#pullRequestCheckout').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);
|
|
|
|
});
|
|
|
|
$('#branchCheckout').removeAttr('disabled');
|
|
|
|
} else {
|
|
|
|
add_option_to_branches('No branches available');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
add_option_to_branches('Failed to connect to github');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_option_to_pulls(text) {
|
|
|
|
option = $('<option>');
|
|
|
|
option.attr('value', text[1]);
|
|
|
|
option.html(text[0]);
|
|
|
|
option.appendTo('#pullRequestVersion');
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_option_to_branches(text) {
|
|
|
|
option = $('<option>');
|
|
|
|
option.attr('value', text);
|
|
|
|
option.html(text);
|
|
|
|
option.appendTo('#branchVersion');
|
2015-02-26 02:04:55 +00:00
|
|
|
}
|