>6,128|63&n):n<55296||57344<=n?r.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),r.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return r}(t)},o=[],void 0===(i="function"==typeof(n=function(){return a})?n.apply(r,o):n)||(t.exports=i)}])});
}
$('a[rel=qr]').fancybox({
padding: 0,
minWidth: 350,
minHeight: 350,
helpers: {
title: null,
overlay: {
locked: false,
css: {'background': 'rgba(0, 0, 0, 0.4)'}
}
},
wrapCSS: 'apikey-qr-dlg',
afterLoad: function() {
var row = $(this.element).closest('div');
this.content = 'App name: ' + row.find('.app-name').text() + '
';
this.inner.prepend('');
$('.apikey-qr-dlg').find('.qr-body').html('').qrcode(
{render: 'image', fill: '#333', radius: 0.5, minVersion: 6, background: null, size: 300, text: row.find('.api-key').text() });
}
});
});
}
};
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');
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 = $('