diff --git a/src/scripts/settings.js b/src/scripts/settings.js index 5c7aa5e..978d56b 100644 --- a/src/scripts/settings.js +++ b/src/scripts/settings.js @@ -7,7 +7,7 @@ settings = {} settings.createConfig = function() { - var msg, + var msg = '', action; action = function(data) { @@ -102,14 +102,14 @@ settings.createConfig = function() { } - msg = "

Enter your database connection details below:"; - msg += ""; - msg += ""; - msg += ""; + msg += "

Enter your database connection details below:"; + msg += ""; + msg += ""; + msg += ""; msg += "

"; msg += "

Lychee will create its own database. If required, you can enter the name of an existing database instead:"; - msg += ""; - msg += ""; + msg += ""; + msg += ""; msg += "

"; basicModal.show({ @@ -184,46 +184,63 @@ settings.createLogin = function() { settings.setLogin = function() { - var old_password, - username, - password, - params, - buttons; + var msg = '', + action; - buttons = [ - ['Change Login', function() { + action = function(data) { - old_password = $('.message input.text#old_password').val(); - username = $('.message input.text#username').val(); - password = $('.message input.text#password').val(); + var oldPassword = data.oldPassword || '', + username = data.username || '', + password = data.password || '', + params; - if (old_password.length<1) { - loadingBar.show('error', 'Your old password was entered incorrectly. Please try again!'); - return false; + if (oldPassword.length<1) { + basicModal.error('oldPassword'); + return false; + } + + if (username.length<1) { + basicModal.error('username'); + return false; + } + + if (password.length<1) { + basicModal.error('password'); + return false; + } + + basicModal.close(); + + params = 'setLogin&oldPassword=' + md5(oldPassword) + '&username=' + escape(username) + '&password=' + md5(password); + lychee.api(params, function(data) { + + if (data!==true) lychee.error(null, params, data); + + }); + + } + + msg += "

Enter your current password:"; + msg += ""; + msg += "

" + msg += "

Your username and password will be changed to the following:"; + msg += ""; + msg += ""; + msg += "

"; + + basicModal.show({ + body: msg, + buttons: { + action: { + title: 'Change Login', + fn: action + }, + cancel: { + title: 'Cancel', + fn: basicModal.close } - - if (username.length<1) { - loadingBar.show('error', 'Your new username was entered incorrectly. Please try again!'); - return false; - } - - if (password.length<1) { - loadingBar.show('error', 'Your new password was entered incorrectly. Please try again!'); - return false; - } - - params = 'setLogin&oldPassword=' + md5(old_password) + '&username=' + escape(username) + '&password=' + md5(password); - lychee.api(params, function(data) { - - if (data!==true) lychee.error(null, params, data); - - }); - - }], - ['Cancel', function() {}] - ]; - - modal.show('Change Login', "Enter your current password:
Your username and password will be changed to the following: ", buttons, -171); + } + }); }