add back templates for index/about, move background animation into class, use clip color for assembly background
This commit is contained in:
parent
3937df7714
commit
43e952c27d
13 changed files with 301 additions and 57 deletions
|
|
@ -120,16 +120,19 @@ function timeupdate(event) {
|
|||
}
|
||||
|
||||
function formatInfo(config, ascroll) {
|
||||
var info = document.createElement('div')
|
||||
var h1 = document.createElement('h1')
|
||||
h1.innerHTML = config.title
|
||||
ascroll.appendChild(h1)
|
||||
info.appendChild(h1)
|
||||
var h2 = document.createElement('h2')
|
||||
h2.innerHTML = config.byline
|
||||
ascroll.appendChild(h2)
|
||||
info.appendChild(h2)
|
||||
var div = document.createElement('div')
|
||||
div.classList.add('intro')
|
||||
div.innerHTML = config.body
|
||||
ascroll.appendChild(div)
|
||||
info.appendChild(div)
|
||||
ascroll.appendChild(info)
|
||||
return info
|
||||
}
|
||||
|
||||
function showOverlay(event) {
|
||||
|
|
@ -181,6 +184,33 @@ function showOverlay(event) {
|
|||
|
||||
}
|
||||
|
||||
async function loadClips(annotations) {
|
||||
var items = annotations.map(annotation => annotation.id.split('/')[0])
|
||||
items = [...new Set(items)]
|
||||
return pandoraAPI('findClips', {itemsQuery: {
|
||||
conditions: [{key: 'id', operator: '&', value: items}]
|
||||
}, range: [0, 10000], keys: [
|
||||
'id', 'hue', 'saturation', 'lightness'
|
||||
]}).then(response => {
|
||||
var colors = {}
|
||||
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)
|
||||
annotation.color1 = colors[clipId]
|
||||
if(previous) {
|
||||
previous.color2 = annotation.color1
|
||||
}
|
||||
previous = annotation
|
||||
})
|
||||
annotations[annotations.length - 1].color2 = annotations[0].color1
|
||||
console.log(annotations)
|
||||
return annotations
|
||||
})
|
||||
}
|
||||
|
||||
function loadItem(config) {
|
||||
pandoraAPI('get', {id: config.item, keys: [
|
||||
'id', 'title', 'layers', 'hue', 'saturation', 'lightness'
|
||||
|
|
@ -198,39 +228,51 @@ function loadItem(config) {
|
|||
video.addEventListener('timeupdate', timeupdate)
|
||||
video.addEventListener('touchstart', showOverlay)
|
||||
video.addEventListener('mouseover', showOverlay)
|
||||
ascroll.appendChild(video)
|
||||
var box = document.createElement('div')
|
||||
box.classList.add('vbox')
|
||||
box.appendChild(video)
|
||||
ascroll.appendChild(box)
|
||||
|
||||
var first
|
||||
formatInfo(config, ascroll)
|
||||
|
||||
response.data.layers[config.layer].forEach(annotation => {
|
||||
var info = formatInfo(config, ascroll)
|
||||
var annotations = response.data.layers[config.layer].filter(annotation => {
|
||||
if (config.user && annotation.user != config.user) {
|
||||
return
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
loadClips(annotations).then(annotations => {
|
||||
annotations.forEach(annotation => {
|
||||
var div = document.createElement('div')
|
||||
div.classList.add('annotation')
|
||||
|
||||
var color1 = `hsl(${annotation.color1.hue}, 70%, 75%)`
|
||||
var color2 = `hsl(${annotation.color2.hue}, 70%, 75%)`
|
||||
if (!first) {
|
||||
first = annotation
|
||||
info.style.background = color1
|
||||
}
|
||||
div.style.background = `linear-gradient(to bottom, ${color1}, ${color2})`;
|
||||
div.innerHTML = `
|
||||
<div class="frame"><img src="${baseURL}/${annotation.id.split('/')[0]}/${imageResolution}p${annotation.in}.jpg"></div>
|
||||
<div class="text">${annotation.value}</div>
|
||||
|
||||
`
|
||||
ascroll.appendChild(div)
|
||||
var frame = div.querySelector('.frame')
|
||||
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
||||
if (loaded && visible) {
|
||||
updatePlayer(video, frame, annotation['in'], annotation['out'])
|
||||
}
|
||||
|
||||
}))
|
||||
})
|
||||
loaded = true
|
||||
let frame = ascroll.querySelector('.annotation .frame')
|
||||
if (frame) {
|
||||
updatePlayer(video, frame, first['in'], first['out'])
|
||||
}
|
||||
if (!first) {
|
||||
first = annotation
|
||||
}
|
||||
var div = document.createElement('div')
|
||||
div.classList.add('annotation')
|
||||
div.innerHTML = `
|
||||
<div class="frame"><img src="${baseURL}/${annotation.id.split('/')[0]}/${imageResolution}p${annotation.in}.jpg"></div>
|
||||
<div class="text">${annotation.value}</div>
|
||||
|
||||
`
|
||||
ascroll.appendChild(div)
|
||||
var frame = div.querySelector('.frame')
|
||||
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
||||
if (loaded && visible) {
|
||||
updatePlayer(video, frame, annotation['in'], annotation['out'])
|
||||
}
|
||||
|
||||
}))
|
||||
})
|
||||
loaded = true
|
||||
let frame = ascroll.querySelector('.annotation .frame')
|
||||
if (frame) {
|
||||
updatePlayer(video, frame, first['in'], first['out'])
|
||||
}
|
||||
})
|
||||
}
|
||||
function loadEdit(config) {
|
||||
|
|
@ -245,23 +287,37 @@ function loadEdit(config) {
|
|||
ascroll.appendChild(video)
|
||||
|
||||
var first
|
||||
formatInfo(config, ascroll)
|
||||
var info = formatInfo(config, ascroll)
|
||||
var previous
|
||||
|
||||
var annotations = []
|
||||
|
||||
response.data.clips.forEach(clip => {
|
||||
clip.layers[config.layer].forEach(annotation => {
|
||||
if (config.user && annotation.user != config.user) {
|
||||
return
|
||||
}
|
||||
if (!first) {
|
||||
first = annotation
|
||||
}
|
||||
annotation.title = clip.title
|
||||
annotations.push(annotation)
|
||||
})
|
||||
})
|
||||
loadClips(annotations).then(annotations => {
|
||||
annotations.forEach(annotation => {
|
||||
var div = document.createElement('div')
|
||||
div.classList.add('annotation')
|
||||
|
||||
var color1 = `hsl(${annotation.color1.hue}, 70%, 75%)`
|
||||
var color2 = `hsl(${annotation.color2.hue}, 70%, 75%)`
|
||||
if (!first) {
|
||||
first = annotation
|
||||
info.style.background = color1
|
||||
}
|
||||
div.style.background = `linear-gradient(to bottom, ${color1}, ${color2})`;
|
||||
div.innerHTML = `
|
||||
<div class="frame">
|
||||
<figure>
|
||||
<img src="${baseURL}/${annotation.id.split('/')[0]}/${imageResolution}p${annotation.in}.jpg">
|
||||
<figcaption><a href="${baseURL}/${annotation.id}" target="_blank">${clip.title}</a></figcaption>
|
||||
<figcaption><a href="${baseURL}/${annotation.id}" target="_blank">${annotation.title}</a></figcaption>
|
||||
</figure>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue