Clean code.

This commit is contained in:
Lars Jung 2016-06-22 21:15:50 +02:00
parent e0fc7043b5
commit 35df02984b

View file

@ -36,16 +36,16 @@ const tplSupport =
const setup = config.setup; const setup = config.setup;
function addTest(label, info, passed, result) { const addTest = (label, info, passed, result) => {
const $test = jq(tplTest).appendTo('#tests'); const $test = jq(tplTest).appendTo('#tests');
$test.find('.label').text(label); $test.find('.label').text(label);
$test.find('.result') $test.find('.result')
.addClass(passed ? 'passed' : 'failed') .addClass(passed ? 'passed' : 'failed')
.text(result ? result : passed ? 'yes' : 'no'); .text(result ? result : passed ? 'yes' : 'no');
$test.find('.info').html(info); $test.find('.info').html(info);
} };
function addTests() { const addTests = () => {
if (!setup.AS_ADMIN) { if (!setup.AS_ADMIN) {
return; return;
} }
@ -131,36 +131,36 @@ function addTests() {
'Shell du', 'Command line program <code>du</code> available', 'Shell du', 'Command line program <code>du</code> available',
setup.HAS_CMD_DU setup.HAS_CMD_DU
); );
} };
function reload() { const reload = () => {
win.location.reload(); win.location.reload();
} };
function onLogin() { const onLogin = () => {
server.request({ server.request({
action: 'login', action: 'login',
pass: jq('#pass').val() pass: jq('#pass').val()
}).then(reload); }).then(reload);
} };
function onLogout() { const onLogout = () => {
server.request({ server.request({
action: 'logout' action: 'logout'
}).then(reload); }).then(reload);
} };
function onKeydown(event) { const onKeydown = event => {
if (event.which === 13) { if (event.which === 13) {
onLogin(); onLogin();
} }
} };
function addSupport() { const addSupport = () => {
jq(tplSupport).appendTo('#content'); jq(tplSupport).appendTo('#content');
} };
function addLogin() { const addLogin = () => {
jq(tplLogin).appendTo('#content'); jq(tplLogin).appendTo('#content');
if (setup.AS_ADMIN) { if (setup.AS_ADMIN) {
@ -175,13 +175,13 @@ function addLogin() {
if (config.options.hasCustomPasshash) { if (config.options.hasCustomPasshash) {
jq('#hint').remove(); jq('#hint').remove();
} }
} };
function init() { const init = () => {
addSupport(); addSupport();
addLogin(); addLogin();
addTests(); addTests();
} };
init(); init();