Syntax adjustments in album.js.

This commit is contained in:
Nils Asmussen 2016-08-03 21:33:50 +02:00
parent 066fc90056
commit adaa23d39f
2 changed files with 21 additions and 16 deletions

View File

@ -3,6 +3,26 @@
* @copyright 2015 by Tobias Reich
*/
const buildAlbumOptions = function(albums, select, parent = 0, layer = 0) {
var cmbxOptions = ''
for (i in albums) {
if (albums[i].parent==parent) {
let title = (layer>0 ? '  '.repeat(layer - 1) + '└ ' : '') + albums[i].title
let selected = select==albums[i].id ? ' selected="selected"' : ''
cmbxOptions += `<option${ selected } value='${ albums[i].id }'>${ title }</option>`
cmbxOptions += buildAlbumOptions(albums, select, albums[i].id, layer + 1)
}
}
return cmbxOptions
}
album = {
json: null,
@ -148,21 +168,6 @@ album.parse = function() {
}
function buildAlbumOptions(albums, select, parent = 0, layer = 0) {
var cmbxOptions = ''
for (i in albums) {
if (albums[i].parent == parent) {
let title = (layer > 0 ? "&nbsp;&nbsp;".repeat(layer - 1) + "└ " : "") + albums[i].title
cmbxOptions += `<option `;
if (select == albums[i].id)
cmbxOptions += `selected="selected" `
cmbxOptions += `value='` + albums[i].id + `'>` + title + `</option>`
cmbxOptions += buildAlbumOptions(albums, select, albums[i].id, layer + 1)
}
}
return cmbxOptions
}
album.add = function(albumID = 0) {
const action = function(data) {

View File

@ -193,7 +193,7 @@ contextMenu.mergeAlbum = function(albumID, e) {
// It's not possible to move them into us
let exclude = [ albumID ]
let a = getAlbumFrom(data.albums, selalbum.parent)
while (a != null) {
while (a!=null) {
exclude.push(a.id)
a = getAlbumFrom(data.albums, a.parent)
}