Updated settings.js (ES2015)

This commit is contained in:
Tobias Reich 2015-07-12 12:42:32 +02:00
parent f3c4662d2c
commit 961026b014
2 changed files with 167 additions and 186 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -7,27 +7,23 @@ settings = {}
settings.createConfig = function() { settings.createConfig = function() {
var msg = '', const action = function(data) {
action;
action = function(data) { let dbName = data.dbName || '',
var dbName = data.dbName || '',
dbUser = data.dbUser || '', dbUser = data.dbUser || '',
dbPassword = data.dbPassword || '', dbPassword = data.dbPassword || '',
dbHost = data.dbHost || '', dbHost = data.dbHost || '',
dbTablePrefix = data.dbTablePrefix || '', dbTablePrefix = data.dbTablePrefix || ''
params;
if (dbUser.length<1) { if (dbUser.length<1) {
basicModal.error('dbUser'); basicModal.error('dbUser')
return false; return false
} }
if (dbHost.length<1) dbHost = 'localhost'; if (dbHost.length<1) dbHost = 'localhost'
if (dbName.length<1) dbName = 'lychee'; if (dbName.length<1) dbName = 'lychee'
params = { let params = {
dbName, dbName,
dbUser, dbUser,
dbPassword, dbPassword,
@ -50,9 +46,9 @@ settings.createConfig = function() {
fn: settings.createConfig fn: settings.createConfig
} }
} }
}); })
return false; return false
} }
@ -67,9 +63,9 @@ settings.createConfig = function() {
fn: settings.createConfig fn: settings.createConfig
} }
} }
}); })
return false; return false
} }
@ -84,9 +80,9 @@ settings.createConfig = function() {
fn: settings.createConfig fn: settings.createConfig
} }
} }
}); })
return false; return false
} }
@ -99,22 +95,22 @@ settings.createConfig = function() {
fn: settings.createConfig fn: settings.createConfig
} }
} }
}); })
return false; return false
} else { } else {
// Configuration successful // Configuration successful
window.location.reload(); window.location.reload()
} }
}); })
} }
msg = ` let msg = `
<p> <p>
Enter your database connection details below: Enter your database connection details below:
<input name='dbHost' class='text' type='text' placeholder='Database Host (optional)' value=''> <input name='dbHost' class='text' type='text' placeholder='Database Host (optional)' value=''>
@ -136,34 +132,30 @@ settings.createConfig = function() {
fn: action fn: action
} }
} }
}); })
} }
settings.createLogin = function() { settings.createLogin = function() {
var action, const action = function(data) {
msg = '';
action = function(data) { let username = data.username,
password = data.password
var params,
username = data.username,
password = data.password;
if (username.length<1) { if (username.length<1) {
basicModal.error('username'); basicModal.error('username')
return false; return false
} }
if (password.length<1) { if (password.length<1) {
basicModal.error('password'); basicModal.error('password')
return false; return false
} }
basicModal.close(); basicModal.close()
params = { let params = {
username, username,
password password
} }
@ -180,15 +172,15 @@ settings.createLogin = function() {
fn: settings.createLogin fn: settings.createLogin
} }
} }
}); })
} }
}); })
} }
msg = ` let msg = `
<p> <p>
Enter a username and password for your installation: Enter a username and password for your installation:
<input name='username' class='text' type='text' placeholder='New Username' value=''> <input name='username' class='text' type='text' placeholder='New Username' value=''>
@ -204,40 +196,36 @@ settings.createLogin = function() {
fn: action fn: action
} }
} }
}); })
} }
settings.setLogin = function() { settings.setLogin = function() {
var msg = '', const action = function(data) {
action;
action = function(data) { let oldPassword = data.oldPassword || '',
var oldPassword = data.oldPassword || '',
username = data.username || '', username = data.username || '',
password = data.password || '', password = data.password || ''
params;
if (oldPassword.length<1) { if (oldPassword.length<1) {
basicModal.error('oldPassword'); basicModal.error('oldPassword')
return false; return false
} }
if (username.length<1) { if (username.length<1) {
basicModal.error('username'); basicModal.error('username')
return false; return false
} }
if (password.length<1) { if (password.length<1) {
basicModal.error('password'); basicModal.error('password')
return false; return false
} }
basicModal.close(); basicModal.close()
params = { let params = {
oldPassword, oldPassword,
username, username,
password password
@ -245,13 +233,13 @@ settings.setLogin = function() {
api.post('Settings::setLogin', params, function(data) { api.post('Settings::setLogin', params, function(data) {
if (data!==true) lychee.error(null, params, data); if (data!==true) lychee.error(null, params, data)
}); })
} }
msg = ` let msg = `
<p> <p>
Enter your current password: Enter your current password:
<input name='oldPassword' class='text' type='password' placeholder='Current Password' value=''> <input name='oldPassword' class='text' type='password' placeholder='Current Password' value=''>
@ -275,31 +263,27 @@ settings.setLogin = function() {
fn: basicModal.close fn: basicModal.close
} }
} }
}); })
} }
settings.setSorting = function() { settings.setSorting = function() {
var sortingPhotos = [], let sortingPhotos = [],
sortingAlbums = [], sortingAlbums = []
action,
msg = '';
action = function() { const action = function() {
var params; sortingAlbums[0] = $('.basicModal select#settings_albums_type').val()
sortingAlbums[1] = $('.basicModal select#settings_albums_order').val()
sortingAlbums[0] = $('.basicModal select#settings_albums_type').val(); sortingPhotos[0] = $('.basicModal select#settings_photos_type').val()
sortingAlbums[1] = $('.basicModal select#settings_albums_order').val(); sortingPhotos[1] = $('.basicModal select#settings_photos_order').val()
sortingPhotos[0] = $('.basicModal select#settings_photos_type').val(); basicModal.close()
sortingPhotos[1] = $('.basicModal select#settings_photos_order').val(); albums.refresh()
basicModal.close(); let params = {
albums.refresh();
params = {
typeAlbums : sortingAlbums[0], typeAlbums : sortingAlbums[0],
orderAlbums : sortingAlbums[1], orderAlbums : sortingAlbums[1],
typePhotos : sortingPhotos[0], typePhotos : sortingPhotos[0],
@ -309,16 +293,16 @@ settings.setSorting = function() {
api.post('Settings::setSorting', params, function(data) { api.post('Settings::setSorting', params, function(data) {
if (data===true) { if (data===true) {
lychee.sortingAlbums = 'ORDER BY ' + sortingAlbums[0] + ' ' + sortingAlbums[1]; lychee.sortingAlbums = 'ORDER BY ' + sortingAlbums[0] + ' ' + sortingAlbums[1]
lychee.sortingPhotos = 'ORDER BY ' + sortingPhotos[0] + ' ' + sortingPhotos[1]; lychee.sortingPhotos = 'ORDER BY ' + sortingPhotos[0] + ' ' + sortingPhotos[1]
lychee.load(); lychee.load()
} else lychee.error(null, params, data); } else lychee.error(null, params, data)
}); })
} }
msg = ` let msg = `
<p> <p>
Sort albums by Sort albums by
<span class="select"> <span class="select">
@ -374,23 +358,23 @@ settings.setSorting = function() {
fn: basicModal.close fn: basicModal.close
} }
} }
}); })
if (lychee.sortingAlbums!=='') { if (lychee.sortingAlbums!=='') {
sortingAlbums = lychee.sortingAlbums.replace('ORDER BY ', '').split(' '); sortingAlbums = lychee.sortingAlbums.replace('ORDER BY ', '').split(' ')
$('.basicModal select#settings_albums_type').val(sortingAlbums[0]); $('.basicModal select#settings_albums_type').val(sortingAlbums[0])
$('.basicModal select#settings_albums_order').val(sortingAlbums[1]); $('.basicModal select#settings_albums_order').val(sortingAlbums[1])
} }
if (lychee.sortingPhotos!=='') { if (lychee.sortingPhotos!=='') {
sortingPhotos = lychee.sortingPhotos.replace('ORDER BY ', '').split(' '); sortingPhotos = lychee.sortingPhotos.replace('ORDER BY ', '').split(' ')
$('.basicModal select#settings_photos_type').val(sortingPhotos[0]); $('.basicModal select#settings_photos_type').val(sortingPhotos[0])
$('.basicModal select#settings_photos_order').val(sortingPhotos[1]); $('.basicModal select#settings_photos_order').val(sortingPhotos[1])
} }
@ -398,32 +382,29 @@ settings.setSorting = function() {
settings.setDropboxKey = function(callback) { settings.setDropboxKey = function(callback) {
var action, const action = function(data) {
msg = "";
action = function(data) { let key = data.key
var key = data.key;
if (data.key.length<1) { if (data.key.length<1) {
basicModal.error('key'); basicModal.error('key')
return false; return false
} }
basicModal.close(); basicModal.close()
api.post('Settings::setDropboxKey', { key }, function(data) { api.post('Settings::setDropboxKey', { key }, function(data) {
if (data===true) { if (data===true) {
lychee.dropboxKey = key; lychee.dropboxKey = key
if (callback) lychee.loadDropbox(callback); if (callback) lychee.loadDropbox(callback)
} else lychee.error(null, params, data); } else lychee.error(null, params, data)
}); })
} }
msg = ` let msg = `
<p> <p>
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: 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:
<input class='text' name='key' type='text' placeholder='Dropbox API Key' value='${ lychee.dropboxKey }'> <input class='text' name='key' type='text' placeholder='Dropbox API Key' value='${ lychee.dropboxKey }'>
@ -442,6 +423,6 @@ settings.setDropboxKey = function(callback) {
fn: basicModal.close fn: basicModal.close
} }
} }
}); })
} }