Updated password.js (ES2015)

This commit is contained in:
Tobias Reich 2015-07-11 16:21:26 +02:00
parent 710aa2bf52
commit 9e976b1856
2 changed files with 25 additions and 31 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -1,5 +1,5 @@
/**
* @description Controls the access to password-protected albums and photos.
* @description Controls the access to password-protected albums and photos.
* @copyright 2015 by Tobias Reich
*/
@ -11,27 +11,25 @@ password = {
password.get = function(albumID, callback, passwd) {
var params;
if (lychee.publicMode===false) callback();
else if (album.json&&album.json.password==='0') callback();
else if (albums.json&&albums.getByID(albumID).password==='0') callback();
else if (!albums.json&&!album.json) {
if (lychee.publicMode===false) callback()
else if (album.json && album.json.password==='0') callback()
else if (albums.json && albums.getByID(albumID).password==='0') callback()
else if (!albums.json && !album.json) {
// Continue without password
album.json = {password: true};
callback('');
album.json = { password: true }
callback('')
} else if (passwd==null) {
// Request password
password.getDialog(albumID, callback);
password.getDialog(albumID, callback)
} else {
// Check password
params = {
let params = {
albumID,
password: passwd
}
@ -39,14 +37,14 @@ password.get = function(albumID, callback, passwd) {
api.post('Album::getPublic', params, function(data) {
if (data===true) {
basicModal.close();
password.value = passwd;
callback();
basicModal.close()
password.value = passwd
callback()
} else {
basicModal.error('password');
basicModal.error('password')
}
});
})
}
@ -54,23 +52,19 @@ password.get = function(albumID, callback, passwd) {
password.getDialog = function(albumID, callback) {
var action,
cancel,
msg = '';
const action = (data) => password.get(albumID, callback, data.password)
action = function(data) { password.get(albumID, callback, data.password) }
cancel = function() {
basicModal.close();
if (visible.albums()===false) lychee.goto();
const cancel = () => {
basicModal.close()
if (visible.albums()===false) lychee.goto()
}
msg = `
<p>
This album is protected by a password. Enter the password below to view the photos of this album:
<input name='password' class='text' type='password' placeholder='password' value=''>
</p>
`
let msg = `
<p>
This album is protected by a password. Enter the password below to view the photos of this album:
<input name='password' class='text' type='password' placeholder='password' value=''>
</p>
`
basicModal.show({
body: msg,
@ -84,6 +78,6 @@ password.getDialog = function(albumID, callback) {
fn: cancel
}
}
});
})
}