diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index e371eed..9a9dd18 100755 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -300,24 +300,22 @@ async function loadClips(annotations) { } function loadAnnotations(config) { + var layers = config.layer + if (!Array.isArray(layers)) { + layers = [layers] + } if (config.item) { pandoraAPI('get', {id: config.item, keys: [ 'layers' ]}).then(response => { var annotations = [] - if (Array.isArray(config.layer)) { - config.layer.forEach(layer => { - response.data.layers[layer].forEach(annotation => { - if (!(config.user && annotation.user != config.user)) { - annotations.push(annotation) - } - }) + layers.forEach(layer => { + response.data.layers[layer].forEach(annotation => { + if (!(config.user && annotation.user != config.user)) { + annotations.push(annotation) + } }) - } else { - annotations = response.data.layers[config.layer].filter(annotation => { - return !(config.user && annotation.user != config.user) - }) - } + }) loadClips(annotations).then(annotations => { config.annotations = annotations.filter(annotation => { if (config.only_e) { @@ -344,24 +342,26 @@ function loadAnnotations(config) { director: clip.director, id: clip.item } - clip.layers[config.layer].forEach(annotation => { - if (config.user && annotation.user != config.user) { - return - } - ;['title', 'director', 'date'].forEach(key => { - annotation[key] = clip[key] + layers.forEach(layer => { + clip.layers[layer].forEach(annotation => { + if (config.user && annotation.user != config.user) { + return + } + ;['title', 'director', 'date'].forEach(key => { + annotation[key] = clip[key] + }) + if (config.only_e) { + if (annotation.value.slice(0, 2) == 'E:') { + annotation.value = annotation.value.slice(2).trim() + annotations.push(annotation) + } + } else { + if (annotation.value.slice(0, 2) != 'E:') { + annotations.push(annotation) + } + } }) - if (config.only_e) { - if (annotation.value.slice(0, 2) == 'E:') { - annotation.value = annotation.value.slice(2).trim() - annotations.push(annotation) - } - } else { - if (annotation.value.slice(0, 2) != 'E:') { - annotations.push(annotation) - } - } - }) + } }) loadClips(annotations).then(annotations => { config.annotations = annotations