Syntax adjustments

This commit is contained in:
Tobias Reich 2016-07-31 15:53:34 +02:00
parent 1020b0d1dc
commit 0c7d95fb15
9 changed files with 78 additions and 56 deletions

View File

@ -9,13 +9,18 @@ use Lychee\Modules\Response;
// Add parent field to albums // Add parent field to albums
$query = Database::prepare($connection, "SELECT `parent` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS)); $query = Database::prepare($connection, "SELECT `parent` FROM `?` LIMIT 1", array(LYCHEE_TABLE_ALBUMS));
if (!Database::execute($connection, $query, "update_030103", __LINE__)) { $result = Database::execute($connection, $query, "update_030103", __LINE__);
if ($result===false) {
$query = Database::prepare($connection, "ALTER TABLE `?` ADD `parent` BIGINT(14) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_ALBUMS)); $query = Database::prepare($connection, "ALTER TABLE `?` ADD `parent` BIGINT(14) NOT NULL DEFAULT 0", array(LYCHEE_TABLE_ALBUMS));
$result = Database::execute($connection, $query, "update_030103", __LINE__); $result = Database::execute($connection, $query, "update_030103", __LINE__);
if (!$result) {
if ($result===false) {
Log::error($database, 'update_030103', __LINE__, 'Could not update database (' . $database->error . ')'); Log::error($database, 'update_030103', __LINE__, 'Could not update database (' . $database->error . ')');
return false; return false;
} }
} }
// Set version // Set version

View File

@ -12,7 +12,7 @@ album = {
album.isSmartID = function(id) { album.isSmartID = function(id) {
return id==='0' || id==='f' || id==='s' || id==='r' return (id==='0' || id==='f' || id==='s' || id==='r')
} }
@ -21,7 +21,7 @@ album.getID = function() {
let id = null let id = null
let isID = (id) => { let isID = (id) => {
if (album.isSmartID(id)) return true if (album.isSmartID(id)===true) return true
return $.isNumeric(id) return $.isNumeric(id)
} }
@ -35,19 +35,18 @@ album.getID = function() {
} }
if (isID(id)===true) return id if (isID(id)===true) return id
else return false
return false
} }
album.getParent = function() { album.getParent = function() {
let id = album.json.id; let id = album.json.id
if (album.isSmartID(id)===true || album.json.parent==0) return ''
if (album.isSmartID(id) || album.json.parent==0) {
return ''
} else {
return album.json.parent return album.json.parent
}
} }
@ -109,7 +108,8 @@ album.load = function(albumID, refresh = false) {
} }
} }
if (!album.isSmartID(albumID)) { if (album.isSmartID(albumID)===false) {
params = { params = {
parent: albumID parent: albumID
} }
@ -125,14 +125,14 @@ album.load = function(albumID, refresh = false) {
if (durationTime>300) waitTime = 0 if (durationTime>300) waitTime = 0
else waitTime = 300 - durationTime else waitTime = 300 - durationTime
setTimeout(() => { setTimeout(finish, waitTime)
finish()
}, waitTime)
}) })
}
else { } else {
finish() finish()
} }
}, waitTime) }, waitTime)
@ -192,17 +192,22 @@ album.add = function(albumID = 0) {
} }
api.post('Albums::get', { api.post('Albums::get', { parent: -1 }, function(data) {
parent: -1
}, function (data) { let cmbxOptions = `
var cmbxOptions = `<select name='parent'>` <select name='parent'>
cmbxOptions += `<option value='0'>- None -</option>` <option value='0'>- None -</option>
cmbxOptions += buildAlbumOptions(data.albums, albumID) ${ buildAlbumOptions(data.albums, albumID) }
cmbxOptions += '</select>' </select>
`
let msg = `
<p>Enter a title for the new album: <input class='text' name='title' type='text' maxlength='50' placeholder='Title' value='Untitled'></p>
<p>Select the parent album:<br/> ${ cmbxOptions }</p>
`
basicModal.show({ basicModal.show({
body: `<p>Enter a title for the new album: <input class='text' name='title' type='text' maxlength='50' placeholder='Title' value='Untitled'></p>` body: msg,
+ `<p>Select the parent album:<br/>` + cmbxOptions + `</p>`,
buttons: { buttons: {
action: { action: {
title: 'Create Album', title: 'Create Album',
@ -214,6 +219,7 @@ album.add = function(albumID = 0) {
} }
} }
}) })
}) })
} }

View File

@ -17,7 +17,7 @@ albums.load = function() {
if (albums.json===null) { if (albums.json===null) {
params = { let params = {
parent: 0 parent: 0
} }

View File

@ -232,7 +232,7 @@ contextMenu.photoMulti = function(photoIDs, e) {
if (subcount && photocount) { if (subcount && photocount) {
$('.photo.active, .album.active').removeClass('active') $('.photo.active, .album.active').removeClass('active')
multiselect.close() multiselect.close()
lychee.error("Please select either albums or photos!") lychee.error('Please select either albums or photos!')
return return
} }
if (subcount) { if (subcount) {

View File

@ -199,7 +199,7 @@ multiselect.getSelection = function(e) {
let id = $(this).data('id') let id = $(this).data('id')
if (id!=null && id!==0 && !album.isSmartID(id)) { if (id!=null && id!==0 && album.isSmartID(id)===false) {
ids.push(id) ids.push(id)
$(this).addClass('active') $(this).addClass('active')

View File

@ -73,7 +73,7 @@ settings.createConfig = function() {
if (data==='Warning: Could not create file!') { if (data==='Warning: Could not create file!') {
basicModal.show({ basicModal.show({
body: "<p>Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look at the readme for more information.</p>", body: `<p>Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look at the readme for more information.</p>`,
buttons: { buttons: {
action: { action: {
title: 'Retry', title: 'Retry',

View File

@ -125,13 +125,17 @@ sidebar.createStructure.photo = function(data) {
// Set value for public // Set value for public
switch (data.public) { switch (data.public) {
case '0' : _public = 'No' case '0':
_public = 'No'
break break
case '1' : _public = 'Yes' case '1':
_public = 'Yes'
break break
case '2' : _public = 'Yes (Album)' case '2':
_public = 'Yes (Album)'
break break
default : _public = '-' default:
_public = '-'
break break
} }

View File

@ -178,18 +178,25 @@ view.album = {
title: function(photoID) { title: function(photoID) {
let ntitle = ''
let prefix = ''
if (album.json.content[photoID]) { if (album.json.content[photoID]) {
ntitle = album.json.content[photoID].title
prefix = '.photo' prefix = '.photo'
} ntitle = album.json.content[photoID].title
else {
} else {
prefix = '.album'
for (i in album.subjson.albums) { for (i in album.subjson.albums) {
if (album.subjson.albums[i].id==photoID) { if (album.subjson.albums[i].id==photoID) {
ntitle = album.subjson.albums[i].title ntitle = album.subjson.albums[i].title
break break
} }
} }
prefix = '.album'
} }
ntitle = lychee.escapeHTML(ntitle) ntitle = lychee.escapeHTML(ntitle)