diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js
index 9a9dd18..04e7579 100755
--- a/app/static/js/ascroll.js
+++ b/app/static/js/ascroll.js
@@ -192,10 +192,11 @@ function showOverlay(event) {
}
-function renderAnnotation(config, video, ascroll, annotation) {
+function renderAnnotation(config, video, ascroll, clip) {
var div = document.createElement('div')
div.classList.add('annotation')
+ var annotation = clip[0]
var color1 = `hsl(${annotation.color1.hue}, 60%, 15%)`
var color2 = `hsl(${annotation.color2.hue}, 60%, 15%)`
if (!config.first) {
@@ -209,7 +210,11 @@ function renderAnnotation(config, video, ascroll, annotation) {
var txt = `${title}`
figcaption = `${txt}`
}
- annotation.value = annotation.value.replace(/src="\//g, `src="${pandoraURL}/`).replace(/href="\//g, `href="${pandoraURL}/`)
+ var values = []
+ clip.forEach(a => {
+ values.push(a.value.replace(/src="\//g, `src="${pandoraURL}/`).replace(/href="\//g, `href="${pandoraURL}/`))
+ })
+ values = values.join('
')
div.innerHTML = `
- ${annotation.value}
+ ${values}
`
ascroll.appendChild(div)
var frame = div.querySelector('.frame')
@@ -280,13 +285,17 @@ async function loadClips(annotations) {
'id', 'hue', 'saturation', 'lightness'
]}).then(response => {
var colors = {}
+ var clips = {}
response.data.items.forEach(clip => {
colors[clip.id] = clip
})
var previous
annotations.forEach(annotation => {
var clipId = annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
+ clips[clipId] = clips[clipId] || []
+ clips[clipId].push(annotation)
annotation.color1 = colors[clipId]
+
if(previous) {
previous.color2 = annotation.color1
}
@@ -295,7 +304,9 @@ async function loadClips(annotations) {
if (annotations.length) {
annotations[annotations.length - 1].color2 = annotations[0].color1
}
- return annotations
+ //return annotations
+ console.log('WTF', Object.values(clips))
+ return Object.values(clips)
})
}
@@ -326,7 +337,7 @@ function loadAnnotations(config) {
return false
}
} else {
- return annotation.value.slice(0, 2) != 'E:'
+ return annotation
}
})
renderAnnotations(config)
@@ -361,7 +372,7 @@ function loadAnnotations(config) {
}
}
})
- }
+ })
})
loadClips(annotations).then(annotations => {
config.annotations = annotations
@@ -374,11 +385,10 @@ function loadAnnotations(config) {
config.layer = config.layer || layer
-if (config.annotations) {
+if (false && config.annotations) {
renderAnnotations(config)
} else {
loadAnnotations(config)
}
-
window.addEventListener('resize', resize, false);
diff --git a/app/text/models.py b/app/text/models.py
index 4ebbe45..f3c0189 100644
--- a/app/text/models.py
+++ b/app/text/models.py
@@ -174,7 +174,7 @@ class Text(models.Model):
if not item_id:
item_id = self.data.get('item')
if item_id:
- item = Film.objects.filter(pandora_id=item_id).first()
+ item = Film.objects.filter(pandora_url=item_id).first()
if item:
for key in ('title', 'title_zh', 'director'):
data['item_' + key] = item.data[key]