aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/assets/js/media.coffee')
-rw-r--r--app/src/main/assets/js/media.coffee29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/src/main/assets/js/media.coffee b/app/src/main/assets/js/media.coffee
new file mode 100644
index 00000000..810c09b7
--- /dev/null
+++ b/app/src/main/assets/js/media.coffee
@@ -0,0 +1,29 @@
+# we will handle media events
+_frostMediaClick = (e) ->
+
+ ###
+ # Commonality; check for valid target
+ ###
+
+ 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
+
+document.addEventListener "click", _frostMediaClick, true
+