Updated to ES6 and added the new modal for setSorting

This commit is contained in:
Tobias Reich 2015-01-29 23:55:13 +01:00
parent 6bbb46d4bf
commit c06f2e0f07

View File

@ -102,15 +102,19 @@ settings.createConfig = function() {
} }
msg += "<p>Enter your database connection details below:"; msg = `
msg += "<input data-name='dbHost' class='text' type='text' placeholder='Database Host (optional)' value=''>"; <p>
msg += "<input data-name='dbUser' class='text' type='text' placeholder='Database Username' value=''>"; Enter your database connection details below:
msg += "<input data-name='dbPassword' class='text' type='password' placeholder='Database Password' value=''>"; <input data-name='dbHost' class='text' type='text' placeholder='Database Host (optional)' value=''>
msg += "</p>"; <input data-name='dbUser' class='text' type='text' placeholder='Database Username' value=''>
msg += "<p>Lychee will create its own database. If required, you can enter the name of an existing database instead:"; <input data-name='dbPassword' class='text' type='password' placeholder='Database Password' value=''>
msg += "<input data-name='dbName' class='text' type='text' placeholder='Database Name (optional)' value=''>"; </p>
msg += "<input data-name='dbTablePrefix' class='text' type='text' placeholder='Table prefix (optional)' value=''>"; <p>
msg += "</p>"; Lychee will create its own database. If required, you can enter the name of an existing database instead:
<input data-name='dbName' class='text' type='text' placeholder='Database Name (optional)' value=''>
<input data-name='dbTablePrefix' class='text' type='text' placeholder='Table prefix (optional)' value=''>
</p>
`
basicModal.show({ basicModal.show({
body: msg, body: msg,
@ -126,47 +130,41 @@ settings.createConfig = function() {
settings.createLogin = function() { settings.createLogin = function() {
var username, var action,
password, msg = '';
params,
buttons;
buttons = [ action = function(data) {
['Create Login', function() {
username = $('.message input.text#username').val(); var params,
password = $('.message input.text#password').val(); username = data.username,
password = data.password;
if (username.length<1||password.length<1) { if (username.length<1) {
basicModal.error('username');
setTimeout(function() {
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; return false;
}
}, 400); if (password.length<1) {
basicModal.error('password');
return false;
}
} else { basicModal.close();
params = 'setLogin&username=' + escape(username) + '&password=' + md5(password); params = 'setLogin&username=' + escape(username) + '&password=' + md5(password);
lychee.api(params, function(data) { lychee.api(params, function(data) {
if (data!==true) { if (data!==true) {
setTimeout(function() { basicModal.show({
body: '<p>Unable to save login. Please try again with another username and password!</p>',
buttons = [ buttons: {
['Retry', function() { setTimeout(settings.createLogin, 400) }], action: {
['', function() {}] title: 'Retry',
]; fn: settings.createLogin
modal.show('Creation Failed', 'Unable to save login. Please try again with another username and password!', buttons, null, false); }
return false; }
});
}, 400);
} }
@ -174,11 +172,23 @@ settings.createLogin = function() {
} }
}], msg = `
['', function() {}] <p>
]; Enter a username and password for your installation:
<input data-name='username' class='text' type='text' placeholder='New Username' value=''>
<input data-name='password' class='text' type='password' placeholder='New Password' value=''>
</p>
`
modal.show('Create Login', "Enter a username and password for your installation: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>", buttons, -122, false); basicModal.show({
body: msg,
buttons: {
action: {
title: 'Create Login',
fn: action
}
}
});
} }
@ -220,13 +230,17 @@ settings.setLogin = function() {
} }
msg += "<p>Enter your current password:"; msg = `
msg += "<input data-name='oldPassword' class='text' type='password' placeholder='Current Password' value=''>"; <p>
msg += "</p>" Enter your current password:
msg += "<p>Your username and password will be changed to the following:"; <input data-name='oldPassword' class='text' type='password' placeholder='Current Password' value=''>
msg += "<input data-name='username' class='text' type='text' placeholder='New Username' value=''>"; </p>
msg += "<input data-name='password' class='text' type='password' placeholder='New Password' value=''>"; <p>
msg += "</p>"; Your username and password will be changed to the following:
<input data-name='username' class='text' type='text' placeholder='New Username' value=''>
<input data-name='password' class='text' type='password' placeholder='New Password' value=''>
</p>
`
basicModal.show({ basicModal.show({
body: msg, body: msg,
@ -246,16 +260,18 @@ settings.setLogin = function() {
settings.setSorting = function() { settings.setSorting = function() {
var buttons, var sorting = [],
sorting, action,
params; msg = '';
buttons = [ action = function() {
['Change Sorting', function() {
sorting[0] = $('select#settings_type').val(); var params;
sorting[1] = $('select#settings_order').val();
sorting[0] = $('.basicModal select#settings_type').val();
sorting[1] = $('.basicModal select#settings_order').val();
basicModal.close();
albums.refresh(); albums.refresh();
params = 'setSorting&type=' + sorting[0] + '&order=' + sorting[1]; params = 'setSorting&type=' + sorting[0] + '&order=' + sorting[1];
@ -268,35 +284,49 @@ settings.setSorting = function() {
}); });
}], }
['Cancel', function() {}]
];
modal.show('Change Sorting', msg = `
"Sort photos by \ <p>
<select id='settings_type'> \ Sort photos by
<option value='id'>Upload Time</option> \ <select id='settings_type'>
<option value='takestamp'>Take Date</option> \ <option value='id'>Upload Time</option>
<option value='title'>Title</option> \ <option value='takestamp'>Take Date</option>
<option value='description'>Description</option> \ <option value='title'>Title</option>
<option value='public'>Public</option> \ <option value='description'>Description</option>
<option value='star'>Star</option> \ <option value='public'>Public</option>
<option value='type'>Photo Format</option> \ <option value='star'>Star</option>
</select> \ <option value='type'>Photo Format</option>
in an \ </select>
<select id='settings_order'> \ in an
<option value='ASC'>Ascending</option> \ <select id='settings_order'>
<option value='DESC'>Descending</option> \ <option value='ASC'>Ascending</option>
</select> \ <option value='DESC'>Descending</option>
order.\ </select>
", buttons); order.
</p>
`
basicModal.show({
body: msg,
buttons: {
action: {
title: 'Change Sorting',
fn: action
},
cancel: {
title: 'Cancel',
fn: basicModal.close
}
}
});
if (lychee.sorting!=='') { if (lychee.sorting!=='') {
sorting = lychee.sorting.replace('ORDER BY ', '').split(' '); sorting = lychee.sorting.replace('ORDER BY ', '').split(' ');
$('select#settings_type').val(sorting[0]); $('.basicModal select#settings_type').val(sorting[0]);
$('select#settings_order').val(sorting[1]); $('.basicModal select#settings_order').val(sorting[1]);
} }
@ -331,10 +361,12 @@ settings.setDropboxKey = function(callback) {
} }
msg += "<p>"; msg = `
msg += "In order to import photos from your Dropbox, you need a valid drop-ins app key from <a href='https://www.dropbox.com/developers/apps/create'>their website</a>. Generate yourself a personal key and enter it below:"; <p>
msg += "<input class='text' data-name='key' type='text' placeholder='Dropbox API Key' value='" + lychee.dropboxKey + "'>"; In order to import photos from your Dropbox, you need a valid drop-ins app key from <a href='https://www.dropbox.com/developers/apps/create'>their website</a>. Generate yourself a personal key and enter it below:
msg += "</p>"; <input class='text' data-name='key' type='text' placeholder='Dropbox API Key' value='${ lychee.dropboxKey }'>
</p>
`
basicModal.show({ basicModal.show({
body: msg, body: msg,