diff options
Diffstat (limited to 'app/src/main/assets/js/media.coffee')
-rw-r--r-- | app/src/main/assets/js/media.coffee | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/app/src/main/assets/js/media.coffee b/app/src/main/assets/js/media.coffee index 810c09b7..a15a5279 100644 --- a/app/src/main/assets/js/media.coffee +++ b/app/src/main/assets/js/media.coffee @@ -1,29 +1,30 @@ # we will handle media events _frostMediaClick = (e) -> - ### - # Commonality; check for valid target - ### + element = e.target or e.srcElement + if !element?.dataset.sigil?.toLowerCase().includes("inlinevideo") + return - element = e.target or e.srcElement - if !element.hasAttribute("data-sigil") or !element.getAttribute("data-sigil").toLowerCase().includes("inlinevideo") - return - console.log "Found inline video" - element = element.parentNode - if !element.hasAttribute("data-store") - return - dataStore = undefined - try - dataStore = JSON.parse(element.getAttribute("data-store")) - catch e - return - if !dataStore.src - return - console.log "Inline video #{dataStore.src}" - Frost?.loadVideo dataStore.src, dataStore.animatedGifVideo - e.stopPropagation() - e.preventDefault() - return + i = 0 + while !element.hasAttribute("data-store") + if ++i > 2 + return + element = element.parentNode -document.addEventListener "click", _frostMediaClick, true + try + dataStore = JSON.parse(element.dataset.store) + catch e + return + url = dataStore.src + + if !url || !url.startsWith("http") + return + + console.log "Inline video #{url}" + if Frost?.loadVideo url, dataStore.animatedGifVideo + e.stopPropagation() + e.preventDefault() + return + +document.addEventListener "click", _frostMediaClick, true
\ No newline at end of file |