2021-11-21 10:16:22 +00:00
|
|
|
var layer = 'keywords'
|
2021-09-30 17:09:42 +00:00
|
|
|
var imageResolution = 480
|
2021-10-22 08:21:43 +00:00
|
|
|
|
2021-10-28 10:00:52 +00:00
|
|
|
function resize() {
|
|
|
|
var video = document.querySelector('video')
|
|
|
|
if (video && video._frame) {
|
2022-09-03 09:21:16 +00:00
|
|
|
var top, rect = video._frame.getBoundingClientRect();
|
|
|
|
if (video._root) {
|
|
|
|
var root_rect = video._root.getBoundingClientRect();
|
|
|
|
top = rect.top - root_rect.top
|
|
|
|
} else {
|
|
|
|
top = rect.top + window.scrollY
|
|
|
|
}
|
|
|
|
video.style.top = top + 'px'
|
2021-10-28 10:00:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-26 12:00:31 +00:00
|
|
|
function updatePlayerRect(video, frame, config) {
|
2022-09-02 11:54:53 +00:00
|
|
|
var top, rect = frame.getBoundingClientRect();
|
2022-09-07 10:12:31 +00:00
|
|
|
if (config.root && config.mode != "single") {
|
2022-09-02 11:54:53 +00:00
|
|
|
var root_rect = config.root.getBoundingClientRect();
|
|
|
|
//console.log('rect.top', rect.top, 'window.scrollY', window.scrollY, 'root_rect.top', root_rect.top)
|
|
|
|
top = rect.top - root_rect.top
|
2022-09-26 12:00:31 +00:00
|
|
|
video.style.left = ''
|
2022-09-02 11:54:53 +00:00
|
|
|
} else {
|
|
|
|
top = rect.top + window.scrollY
|
2022-09-26 12:00:31 +00:00
|
|
|
video.style.left = rect.x + 'px'
|
2022-09-02 11:54:53 +00:00
|
|
|
}
|
|
|
|
video.style.top = top + 'px'
|
2021-09-30 17:09:42 +00:00
|
|
|
video.style.display = 'block';
|
2022-09-03 09:21:16 +00:00
|
|
|
video.style.maxWidth = rect.width + 'px'
|
2022-09-26 12:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function updatePlayer(video, frame, currentTime, out, src, config) {
|
|
|
|
video.style.opacity = 0
|
|
|
|
//console.log('update player', currentTime, out, src)
|
|
|
|
updatePlayerRect(video, frame, config)
|
|
|
|
if (src && config.loaded) {
|
2021-10-22 08:21:43 +00:00
|
|
|
setVideoSrc(video, src)
|
2021-10-10 15:06:43 +00:00
|
|
|
}
|
2021-09-30 17:09:42 +00:00
|
|
|
//video.poster = frame.querySelector('img').src
|
2021-10-11 18:43:44 +00:00
|
|
|
var muted = video.muted
|
2021-10-28 17:05:59 +00:00
|
|
|
// video.muted = true
|
2021-09-30 17:09:42 +00:00
|
|
|
video.currentTime = currentTime
|
2021-10-10 15:46:19 +00:00
|
|
|
video.dataset.in = currentTime
|
|
|
|
video.dataset.out = out
|
2022-09-03 09:21:16 +00:00
|
|
|
video._root = config.root
|
2021-10-11 09:28:51 +00:00
|
|
|
video._frame = frame
|
2022-09-07 10:12:31 +00:00
|
|
|
if (config.mode == "single") {
|
|
|
|
video._text = frame.parentElement.querySelector('.text')
|
|
|
|
} else {
|
|
|
|
video._text = null
|
|
|
|
}
|
2021-10-11 18:43:44 +00:00
|
|
|
const show = event => {
|
|
|
|
video.style.opacity = 1
|
|
|
|
video.muted = muted
|
|
|
|
video.removeEventListener('seeked', show)
|
|
|
|
}
|
|
|
|
video.addEventListener('seeked', show)
|
2021-09-30 17:09:42 +00:00
|
|
|
video.play()
|
|
|
|
}
|
|
|
|
|
2021-10-11 09:28:51 +00:00
|
|
|
|
2021-10-10 15:46:19 +00:00
|
|
|
function timeupdate(event) {
|
|
|
|
if (event.target.dataset.out && event.target.dataset.in) {
|
|
|
|
var in_= parseFloat(event.target.dataset.in)
|
|
|
|
var out_= parseFloat(event.target.dataset.out)
|
2022-09-07 10:12:31 +00:00
|
|
|
var currentTime = event.target.currentTime
|
|
|
|
if (event.target._text) {
|
|
|
|
event.target._text.querySelectorAll('.annotation').forEach(annot => {
|
|
|
|
var ain = parseFloat(annot.dataset.in)
|
|
|
|
var aout = parseFloat(annot.dataset.out)
|
|
|
|
if (ain <= currentTime && aout > currentTime) {
|
2022-09-26 21:08:29 +00:00
|
|
|
annot.style.display = ''
|
2022-09-07 10:12:31 +00:00
|
|
|
} else {
|
2022-09-26 21:08:29 +00:00
|
|
|
annot.style.display = 'none'
|
2022-09-07 10:12:31 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
2021-10-10 15:46:19 +00:00
|
|
|
if (event.target.currentTime >= out_) {
|
2021-10-11 09:28:51 +00:00
|
|
|
/*
|
|
|
|
var next
|
|
|
|
if (event.target._frame) {
|
|
|
|
next = event.target._frame.parentElement.nextSibling
|
|
|
|
if (next) {
|
|
|
|
next = next.querySelector('.frame')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (next) {
|
|
|
|
scrollTo(next)
|
|
|
|
} else {
|
|
|
|
event.target.pause()
|
|
|
|
}
|
|
|
|
*/
|
2021-10-13 16:12:16 +00:00
|
|
|
if (config.pause) {
|
|
|
|
event.target.pause()
|
|
|
|
} else {
|
|
|
|
event.target.currentTime = in_
|
|
|
|
}
|
2021-10-10 15:46:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:50:19 +00:00
|
|
|
function formatInfo(config, ascroll) {
|
2021-10-21 15:24:26 +00:00
|
|
|
var info = document.createElement('div')
|
2022-09-02 11:54:53 +00:00
|
|
|
if (config.title) {
|
|
|
|
var h1 = document.createElement('h1')
|
|
|
|
h1.innerHTML = config.title
|
|
|
|
info.appendChild(h1)
|
|
|
|
}
|
|
|
|
if (config.byline) {
|
|
|
|
var h2 = document.createElement('h2')
|
|
|
|
h2.innerHTML = config.byline
|
|
|
|
info.appendChild(h2)
|
|
|
|
}
|
2022-09-26 12:00:31 +00:00
|
|
|
if (config.annotations.length && config.body) {
|
2022-09-02 11:54:53 +00:00
|
|
|
var div = document.createElement('div')
|
|
|
|
div.classList.add('intro')
|
|
|
|
div.innerHTML = config.body
|
|
|
|
info.appendChild(div)
|
|
|
|
}
|
2021-10-21 15:24:26 +00:00
|
|
|
ascroll.appendChild(info)
|
2022-09-26 12:00:31 +00:00
|
|
|
if (!config.annotations.length && config.body) {
|
|
|
|
var div = document.createElement('div')
|
|
|
|
div.innerHTML = config.body
|
2022-09-26 13:35:16 +00:00
|
|
|
var activate
|
|
|
|
var part = document.location.hash.slice(1) || 'part1'
|
|
|
|
div.querySelectorAll("h3.toggle").forEach(title => {
|
|
|
|
var section = title.nextElementSibling
|
|
|
|
if (part == title.id && section.style.display == "none") {
|
|
|
|
activate = title
|
|
|
|
}
|
|
|
|
title.onclick = event => {
|
|
|
|
section.style.display = section.style.display == "none" ? "block" : "none"
|
|
|
|
div.querySelectorAll("h3.toggle").forEach(other => {
|
|
|
|
if (other != title) {
|
|
|
|
var osection = other.nextElementSibling
|
|
|
|
osection.style.display = "none"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (activate) {
|
|
|
|
activate.click()
|
|
|
|
}
|
2022-09-26 12:00:31 +00:00
|
|
|
ascroll.appendChild(div)
|
|
|
|
}
|
2021-10-21 15:24:26 +00:00
|
|
|
return info
|
2021-10-11 13:50:19 +00:00
|
|
|
}
|
|
|
|
|
2022-09-03 09:21:16 +00:00
|
|
|
function renderAnnotation(config, video, root, clip) {
|
2021-10-22 11:25:32 +00:00
|
|
|
var div = document.createElement('div')
|
|
|
|
div.classList.add('annotation')
|
2021-11-24 11:20:27 +00:00
|
|
|
var annotation = clip.annotations[0]
|
|
|
|
var color1 = `hsl(${clip.color1.hue}, 60%, 15%)`
|
|
|
|
var color2 = `hsl(${clip.color2.hue}, 60%, 15%)`
|
2021-10-22 11:25:32 +00:00
|
|
|
if (!config.first) {
|
|
|
|
config.first = annotation
|
|
|
|
config.info.style.background = color1
|
|
|
|
}
|
|
|
|
div.style.background = `linear-gradient(to bottom, ${color1}, ${color2})`;
|
|
|
|
var figcaption = ''
|
|
|
|
if (annotation.title) {
|
2021-11-22 22:02:23 +00:00
|
|
|
var title = annotation.title
|
|
|
|
var txt = `${title}`
|
2021-11-21 09:09:26 +00:00
|
|
|
figcaption = `<figcaption><a href="${pandoraURL}/${annotation.id}" target="_blank">${txt}</a></figcaption>`
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
2021-11-24 11:05:09 +00:00
|
|
|
var values = []
|
2021-11-24 11:20:27 +00:00
|
|
|
clip.annotations.forEach(a => {
|
2023-03-02 15:30:29 +00:00
|
|
|
values.push(a.value.replace(/src="\//g, `src="${streamPrefix}/`).replace(/href="\//g, `href="${pandoraURL}/`))
|
2021-11-24 11:05:09 +00:00
|
|
|
})
|
|
|
|
values = values.join('<br><br>')
|
2021-10-22 11:25:32 +00:00
|
|
|
div.innerHTML = `
|
|
|
|
<div class="frame">
|
|
|
|
<figure>
|
2023-03-02 15:30:29 +00:00
|
|
|
<img src="${streamPrefix}/${annotation.id.split('/')[0]}/${imageResolution}p${annotation.in}.jpg">
|
2021-10-22 11:25:32 +00:00
|
|
|
${figcaption}
|
|
|
|
</figure>
|
|
|
|
</div>
|
2021-11-24 11:05:09 +00:00
|
|
|
<div class="text">${values}</div>
|
2021-10-22 11:25:32 +00:00
|
|
|
`
|
2022-09-03 09:21:16 +00:00
|
|
|
root.appendChild(div)
|
2021-10-22 11:25:32 +00:00
|
|
|
var frame = div.querySelector('.frame')
|
|
|
|
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
|
|
|
var src
|
2022-09-03 09:21:16 +00:00
|
|
|
if (clip.src) {
|
|
|
|
src = clip.src
|
|
|
|
} else if (config.edit) {
|
2023-03-02 15:30:29 +00:00
|
|
|
src = `${streamPrefix}/${annotation.id.split('/')[0]}/480p.webm`
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
|
|
|
if (config.loaded && visible) {
|
2022-09-02 11:54:53 +00:00
|
|
|
updatePlayer(video, frame, annotation['in'], annotation['out'], src, config)
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
|
|
|
}))
|
2022-09-26 12:00:31 +00:00
|
|
|
window.addEventListener('resize', () => {
|
2022-09-26 12:35:41 +00:00
|
|
|
var visible = video._frame == frame;
|
2022-09-26 12:00:31 +00:00
|
|
|
if (config.loaded && visible) {
|
|
|
|
updatePlayerRect(video, frame, config)
|
|
|
|
}
|
|
|
|
}, false);
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderAnnotations(config) {
|
2022-09-03 09:21:16 +00:00
|
|
|
//console.log('renderAnnotations', config.item, config.annotations.length)
|
2022-09-02 11:54:53 +00:00
|
|
|
var ascroll = config.root ? config.root : document.querySelector('#ascroll')
|
2021-10-22 11:25:32 +00:00
|
|
|
config.loaded = false
|
|
|
|
var video = document.createElement('video')
|
|
|
|
video.classList.add('player')
|
|
|
|
video.playsinline = true
|
2021-10-25 08:47:29 +00:00
|
|
|
video.setAttribute('playsinline', 'playsinline')
|
|
|
|
video.setAttribute('webkit-playsinline', 'webkit-playsinline')
|
|
|
|
video.WebKitPlaysInline = true
|
2021-10-22 11:25:32 +00:00
|
|
|
video.muted = true
|
|
|
|
if (config.item) {
|
2023-03-02 15:30:29 +00:00
|
|
|
setVideoSrc(video, `${streamPrefix}/${config.item}/480p.webm`)
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
|
|
|
video.addEventListener('timeupdate', timeupdate)
|
|
|
|
video.addEventListener('touchstart', showOverlay)
|
|
|
|
video.addEventListener('mouseover', showOverlay)
|
|
|
|
var box = document.createElement('div')
|
|
|
|
box.classList.add('vbox')
|
|
|
|
box.appendChild(video)
|
|
|
|
ascroll.appendChild(box)
|
|
|
|
|
|
|
|
config.info = formatInfo(config, ascroll)
|
|
|
|
config.annotations.forEach(annotation => {
|
|
|
|
renderAnnotation(config, video, ascroll, annotation)
|
|
|
|
})
|
|
|
|
config.loaded = true
|
|
|
|
if (config.first) {
|
|
|
|
let frame = ascroll.querySelector('.annotation .frame')
|
|
|
|
if (frame) {
|
|
|
|
var src
|
|
|
|
if (config.edit) {
|
2023-03-02 15:30:29 +00:00
|
|
|
src = `${streamPrefix}/${config.first.id.split('/')[0]}/480p.webm`
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
2022-09-02 11:54:53 +00:00
|
|
|
updatePlayer(video, frame, config.first['in'], config.first['out'], src, config)
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 15:24:26 +00:00
|
|
|
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 = {}
|
2021-11-24 11:05:09 +00:00
|
|
|
var clips = {}
|
2021-10-21 15:24:26 +00:00
|
|
|
response.data.items.forEach(clip => {
|
|
|
|
colors[clip.id] = clip
|
|
|
|
})
|
|
|
|
var previous
|
2021-11-24 11:20:27 +00:00
|
|
|
|
2021-10-21 15:24:26 +00:00
|
|
|
annotations.forEach(annotation => {
|
2022-09-07 10:19:39 +00:00
|
|
|
var clipId = annotation.clipId || annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
|
2021-11-24 13:09:01 +00:00
|
|
|
if (!colors[clipId]) {
|
2022-09-07 10:19:39 +00:00
|
|
|
console.log('no match for clip', clipId)
|
2021-11-24 13:09:01 +00:00
|
|
|
return
|
|
|
|
}
|
2021-11-24 11:20:27 +00:00
|
|
|
clips[clipId] = clips[clipId] || {
|
|
|
|
id: clipId,
|
|
|
|
color1: colors[clipId],
|
|
|
|
annotations: []
|
|
|
|
}
|
|
|
|
clips[clipId].annotations.push(annotation)
|
2021-10-21 15:24:26 +00:00
|
|
|
annotation.color1 = colors[clipId]
|
2021-11-24 11:20:27 +00:00
|
|
|
if(previous && previous.id != clipId) {
|
|
|
|
previous.color2 = clips[clipId].color1
|
|
|
|
}
|
|
|
|
if (!previous || previous.id != clipId) {
|
|
|
|
previous = clips[clipId]
|
2021-10-21 15:24:26 +00:00
|
|
|
}
|
|
|
|
})
|
2021-11-24 11:20:27 +00:00
|
|
|
var clips = Object.values(clips)
|
|
|
|
if (clips.length) {
|
|
|
|
clips[clips.length - 1].color2 = clips[0].color1
|
2021-10-21 15:39:49 +00:00
|
|
|
}
|
2021-11-24 11:05:09 +00:00
|
|
|
//return annotations
|
2021-11-24 11:20:27 +00:00
|
|
|
return clips
|
2021-10-21 15:24:26 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-09-03 09:21:16 +00:00
|
|
|
async function loadAnnotations(config) {
|
2022-09-02 11:54:53 +00:00
|
|
|
var layers = config.layer || config.layers || []
|
2021-11-24 10:53:13 +00:00
|
|
|
if (!Array.isArray(layers)) {
|
|
|
|
layers = [layers]
|
|
|
|
}
|
2022-09-02 11:54:53 +00:00
|
|
|
if (config.item && !layers.length) {
|
|
|
|
// load player only view
|
|
|
|
config.annotations = [
|
|
|
|
{
|
|
|
|
"in": config["in"],
|
|
|
|
"out": config["out"],
|
|
|
|
"id": config["item"] + "/" + config["in"].toFixed(3) + '-'+ config.out.toFixed(3),
|
|
|
|
"annotations": [{
|
|
|
|
"id": config["item"] + "/" + config["in"].toFixed(3) + '-'+ config.out.toFixed(3),
|
|
|
|
"value": "",
|
|
|
|
"in": config["in"],
|
|
|
|
"out": config["out"],
|
|
|
|
}],
|
|
|
|
"color1": "",
|
|
|
|
"color2": "",
|
|
|
|
}
|
|
|
|
]
|
2022-09-03 09:21:16 +00:00
|
|
|
return config
|
2022-09-02 11:54:53 +00:00
|
|
|
} else if (config.item) {
|
2022-09-03 09:21:16 +00:00
|
|
|
return pandoraAPI('get', {id: config.item, keys: [
|
2021-10-26 10:47:33 +00:00
|
|
|
'layers'
|
|
|
|
]}).then(response => {
|
2021-11-24 10:47:47 +00:00
|
|
|
var annotations = []
|
2021-11-24 10:53:13 +00:00
|
|
|
layers.forEach(layer => {
|
2022-09-02 11:54:53 +00:00
|
|
|
if (!response.data.layers[layer]) {
|
|
|
|
console.log("ERROR", config.item, layer, "missing", config.root)
|
|
|
|
}
|
|
|
|
response.data.layers[layer] && response.data.layers[layer].forEach(annotation => {
|
2022-09-06 20:31:25 +00:00
|
|
|
annotation.clipId = annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
|
2022-09-02 11:54:53 +00:00
|
|
|
if (!(config.user && annotation.user != config.user) && isInside(config, annotation)) {
|
2021-11-24 10:53:13 +00:00
|
|
|
annotations.push(annotation)
|
|
|
|
}
|
2021-11-24 10:47:47 +00:00
|
|
|
})
|
2021-11-24 10:53:13 +00:00
|
|
|
})
|
2022-09-03 09:21:16 +00:00
|
|
|
return loadClips(annotations).then(annotations => {
|
2021-10-29 14:04:34 +00:00
|
|
|
config.annotations = annotations.filter(annotation => {
|
|
|
|
if (config.only_e) {
|
|
|
|
if (annotation.value.slice(0, 2) == 'E:') {
|
|
|
|
annotation.value = annotation.value.slice(2).trim()
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
} else {
|
2021-11-24 11:05:09 +00:00
|
|
|
return annotation
|
2021-10-29 14:04:34 +00:00
|
|
|
}
|
|
|
|
})
|
2022-09-03 09:21:16 +00:00
|
|
|
return config
|
2021-10-21 15:24:26 +00:00
|
|
|
})
|
|
|
|
})
|
2021-10-22 11:25:32 +00:00
|
|
|
} else {
|
2021-11-01 10:44:09 +00:00
|
|
|
var cited = {}
|
2022-08-31 08:59:08 +00:00
|
|
|
if (config.edit) {
|
2022-09-03 09:21:16 +00:00
|
|
|
return pandoraAPI('getEdit', {id: config.edit, keys: []}).then(response => {
|
2022-08-31 08:59:08 +00:00
|
|
|
var annotations = []
|
|
|
|
response.data.clips.forEach(clip => {
|
|
|
|
cited[clip.item] = {
|
|
|
|
title: clip.title,
|
|
|
|
director: clip.director,
|
|
|
|
id: clip.item
|
|
|
|
}
|
|
|
|
layers.forEach(layer => {
|
|
|
|
clip.layers[layer].forEach(annotation => {
|
|
|
|
if (config.user && annotation.user != config.user) {
|
|
|
|
return
|
2021-11-24 10:53:13 +00:00
|
|
|
}
|
2022-08-31 08:59:08 +00:00
|
|
|
;['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)
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
})
|
2021-11-24 10:53:13 +00:00
|
|
|
})
|
2021-11-24 11:05:09 +00:00
|
|
|
})
|
2022-09-03 09:21:16 +00:00
|
|
|
return loadClips(annotations).then(annotations => {
|
2022-08-31 08:59:08 +00:00
|
|
|
config.annotations = annotations
|
|
|
|
config.cited = Object.values(cited)
|
2022-09-03 09:21:16 +00:00
|
|
|
return config
|
2022-08-31 08:59:08 +00:00
|
|
|
})
|
2021-10-22 11:25:32 +00:00
|
|
|
})
|
2022-08-31 08:59:08 +00:00
|
|
|
} else {
|
|
|
|
if (!config.annotations) {
|
|
|
|
config.annotations = []
|
|
|
|
}
|
2022-09-03 09:21:16 +00:00
|
|
|
return config
|
2022-09-02 11:54:53 +00:00
|
|
|
}
|
2021-10-22 11:25:32 +00:00
|
|
|
}
|
2021-10-10 15:06:43 +00:00
|
|
|
}
|
|
|
|
|
2022-09-07 10:12:31 +00:00
|
|
|
|
|
|
|
function renderSingleMode(config) {
|
|
|
|
var src
|
|
|
|
config.annotations.forEach(annotation => {
|
2023-03-02 15:30:29 +00:00
|
|
|
src = annotation.src = `${streamPrefix}/${annotation.id.split('/')[0]}/480p.webm`
|
2022-09-07 10:12:31 +00:00
|
|
|
})
|
|
|
|
var div = document.createElement('div')
|
|
|
|
var annotation = config.annotations[0].annotations[0]
|
|
|
|
var figcaption = ''
|
|
|
|
div.classList.add('single-node')
|
|
|
|
div.classList.add('annotation')
|
|
|
|
div.innerHTML = `
|
|
|
|
<div class="frame">
|
|
|
|
<figure>
|
2023-03-02 15:30:29 +00:00
|
|
|
<img src="${streamPrefix}/${annotation.id.split('/')[0]}/${imageResolution}p${annotation.in}.jpg">
|
2022-09-07 10:12:31 +00:00
|
|
|
${figcaption}
|
|
|
|
</figure>
|
|
|
|
</div>
|
|
|
|
<div class="text"></div>
|
|
|
|
`
|
|
|
|
config.root.appendChild(div)
|
|
|
|
var frame = div.querySelector('.frame')
|
|
|
|
var text = div.querySelector('.text')
|
2022-09-26 17:31:00 +00:00
|
|
|
var first = config.annotations[0]
|
|
|
|
if (text && first) {
|
|
|
|
var color1 = `hsl(${first.color1.hue}, 60%, 15%)`
|
|
|
|
div.style.background = `${color1}`;
|
|
|
|
}
|
2022-09-07 10:12:31 +00:00
|
|
|
document.addEventListener('scroll', onVisibilityChange(div.querySelector('.frame'), function(visible) {
|
|
|
|
if (config.loaded && visible) {
|
|
|
|
updatePlayer(config.video, frame, config['in'], config['out'], src, config)
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
config.annotations.forEach(clip => {
|
|
|
|
var values = []
|
|
|
|
clip.annotations.forEach(a => {
|
2023-03-02 15:30:29 +00:00
|
|
|
values.push(a.value.replace(/src="\//g, `src="${streamPrefix}/`).replace(/href="\//g, `href="${pandoraURL}/`))
|
2022-09-07 10:12:31 +00:00
|
|
|
})
|
|
|
|
values = values.join('<br><br>')
|
|
|
|
var annot = document.createElement('div')
|
|
|
|
annot.classList.add('annotation')
|
|
|
|
annot.innerHTML = values
|
2022-09-26 12:00:31 +00:00
|
|
|
//console.log(clip)
|
2022-09-07 10:12:31 +00:00
|
|
|
annot.dataset['in'] = clip.annotations[0]['in']
|
|
|
|
annot.dataset['out'] = clip.annotations[0]['out']
|
2022-09-26 21:08:29 +00:00
|
|
|
annot.style.display = 'none'
|
2022-09-07 10:12:31 +00:00
|
|
|
text.appendChild(annot)
|
|
|
|
})
|
|
|
|
if (frame) {
|
|
|
|
updatePlayer(config.video, frame, config['in'], config['out'], src, config)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-21 13:39:38 +00:00
|
|
|
config.layer = config.layer || layer
|
|
|
|
|
2021-11-24 11:05:09 +00:00
|
|
|
if (false && config.annotations) {
|
2021-10-22 11:25:32 +00:00
|
|
|
renderAnnotations(config)
|
|
|
|
} else {
|
2022-09-03 09:21:16 +00:00
|
|
|
loadAnnotations(config).then(renderAnnotations)
|
2021-10-10 15:06:43 +00:00
|
|
|
}
|
2021-10-28 10:00:52 +00:00
|
|
|
|
|
|
|
window.addEventListener('resize', resize, false);
|