diff --git a/src/scripts/settings.js b/src/scripts/settings.js index db742ea..67cbfd7 100644 --- a/src/scripts/settings.js +++ b/src/scripts/settings.js @@ -102,15 +102,19 @@ settings.createConfig = function() { } - 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 = ` +

+ Enter your database connection details below: + + + +

+

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

+ ` basicModal.show({ body: msg, @@ -126,59 +130,65 @@ settings.createConfig = function() { settings.createLogin = function() { - var username, - password, - params, - buttons; + var action, + msg = ''; - buttons = [ - ['Create Login', function() { + action = function(data) { - username = $('.message input.text#username').val(); - password = $('.message input.text#password').val(); + var params, + username = data.username, + password = data.password; - if (username.length<1||password.length<1) { + if (username.length<1) { + basicModal.error('username'); + return false; + } - setTimeout(function() { + if (password.length<1) { + basicModal.error('password'); + return false; + } - buttons = [ - ['Retry', function() { setTimeout(settings.createLogin, 400) }], - ['', function() {}] - ]; - modal.show('Wrong Input', 'The username or password you entered is not long enough. Please try again with another username and password!', buttons, null, false); - return false; + basicModal.close(); - }, 400); + params = 'setLogin&username=' + escape(username) + '&password=' + md5(password); + lychee.api(params, function(data) { - } else { - - params = 'setLogin&username=' + escape(username) + '&password=' + md5(password); - lychee.api(params, function(data) { - - if (data!==true) { - - setTimeout(function() { - - buttons = [ - ['Retry', function() { setTimeout(settings.createLogin, 400) }], - ['', function() {}] - ]; - modal.show('Creation Failed', 'Unable to save login. Please try again with another username and password!', buttons, null, false); - return false; - - }, 400); + if (data!==true) { + basicModal.show({ + body: '

Unable to save login. Please try again with another username and password!

', + buttons: { + action: { + title: 'Retry', + fn: settings.createLogin + } } - }); } - }], - ['', function() {}] - ]; + }); - modal.show('Create Login', "Enter a username and password for your installation: ", buttons, -122, false); + } + + msg = ` +

+ Enter a username and password for your installation: + + +

+ ` + + basicModal.show({ + body: msg, + buttons: { + action: { + title: 'Create Login', + fn: action + } + } + }); } @@ -220,13 +230,17 @@ settings.setLogin = function() { } - msg += "

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

" - msg += "

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

"; + msg = ` +

+ Enter your current password: + +

+

+ Your username and password will be changed to the following: + + +

+ ` basicModal.show({ body: msg, @@ -246,57 +260,73 @@ settings.setLogin = function() { settings.setSorting = function() { - var buttons, - sorting, - params; + var sorting = [], + action, + msg = ''; - buttons = [ - ['Change Sorting', function() { + action = function() { - sorting[0] = $('select#settings_type').val(); - sorting[1] = $('select#settings_order').val(); + var params; - albums.refresh(); + sorting[0] = $('.basicModal select#settings_type').val(); + sorting[1] = $('.basicModal select#settings_order').val(); - params = 'setSorting&type=' + sorting[0] + '&order=' + sorting[1]; - lychee.api(params, function(data) { + basicModal.close(); + albums.refresh(); - if (data===true) { - lychee.sorting = 'ORDER BY ' + sorting[0] + ' ' + sorting[1]; - lychee.load(); - } else lychee.error(null, params, data); + params = 'setSorting&type=' + sorting[0] + '&order=' + sorting[1]; + lychee.api(params, function(data) { - }); + if (data===true) { + lychee.sorting = 'ORDER BY ' + sorting[0] + ' ' + sorting[1]; + lychee.load(); + } else lychee.error(null, params, data); - }], - ['Cancel', function() {}] - ]; + }); - modal.show('Change Sorting', - "Sort photos by \ - \ - in an \ - \ - order.\ - ", buttons); + } + + msg = ` +

+ Sort photos by + + in an + + order. +

+ ` + + basicModal.show({ + body: msg, + buttons: { + action: { + title: 'Change Sorting', + fn: action + }, + cancel: { + title: 'Cancel', + fn: basicModal.close + } + } + }); if (lychee.sorting!=='') { sorting = lychee.sorting.replace('ORDER BY ', '').split(' '); - $('select#settings_type').val(sorting[0]); - $('select#settings_order').val(sorting[1]); + $('.basicModal select#settings_type').val(sorting[0]); + $('.basicModal select#settings_order').val(sorting[1]); } @@ -331,10 +361,12 @@ settings.setDropboxKey = function(callback) { } - msg += "

"; - msg += "In order to import photos from your Dropbox, you need a valid drop-ins app key from their website. Generate yourself a personal key and enter it below:"; - msg += ""; - msg += "

"; + msg = ` +

+ In order to import photos from your Dropbox, you need a valid drop-ins app key from their website. Generate yourself a personal key and enter it below: + +

+ ` basicModal.show({ body: msg,