diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index 2ad9d50..3da38a6 100755 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -19,7 +19,7 @@ function updatePlayer(video, frame, currentTime, out, src, config) { //console.log('update player', currentTime, out, src) var top, rect = frame.getBoundingClientRect(); video.style.opacity = 0 - if (config.root) { + if (config.root && config.mode != "single") { 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 @@ -40,6 +40,11 @@ function updatePlayer(video, frame, currentTime, out, src, config) { video.dataset.out = out video._root = config.root video._frame = frame + if (config.mode == "single") { + video._text = frame.parentElement.querySelector('.text') + } else { + video._text = null + } const show = event => { video.style.opacity = 1 video.muted = muted @@ -54,6 +59,19 @@ 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) + 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) { + annot.style.display = '' + } else { + annot.style.display = 'none' + } + }) + + } if (event.target.currentTime >= out_) { /* var next @@ -330,6 +348,56 @@ async function loadAnnotations(config) { } } + +function renderSingleMode(config) { + var src + config.annotations.forEach(annotation => { + src = annotation.src = `${streamPrefix}/${annotation.id.split('/')[0]}/480p.webm` + }) + 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 = ` +