aboutsummaryrefslogtreecommitdiff
path: root/app/src/web/assets/js/media.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/web/assets/js/media.js')
-rw-r--r--app/src/web/assets/js/media.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/src/web/assets/js/media.js b/app/src/web/assets/js/media.js
new file mode 100644
index 00000000..571168d6
--- /dev/null
+++ b/app/src/web/assets/js/media.js
@@ -0,0 +1,43 @@
+"use strict";
+// Handles media events
+(function () {
+ var _frostMediaClick = function (e) {
+ var target = e.target || e.srcElement;
+ if (!(target instanceof HTMLElement)) {
+ return;
+ }
+ var element = target;
+ var dataset = element.dataset;
+ if (!dataset || !dataset.sigil || dataset.sigil.toLowerCase().indexOf('inlinevideo') == -1) {
+ return;
+ }
+ var i = 0;
+ while (!element.hasAttribute('data-store')) {
+ if (++i > 2) {
+ return;
+ }
+ element = element.parentNode;
+ }
+ var store = element.dataset.store;
+ if (!store) {
+ return;
+ }
+ var dataStore;
+ try {
+ dataStore = JSON.parse(store);
+ }
+ catch (e) {
+ return;
+ }
+ var url = dataStore.src;
+ // !startsWith; see https://stackoverflow.com/a/36876507/4407321
+ if (!url || url.lastIndexOf('http', 0) !== 0) {
+ return;
+ }
+ console.log("Inline video " + url);
+ if (Frost.loadVideo(url, dataStore.animatedGifVideo || false)) {
+ e.stopPropagation();
+ }
+ };
+ document.addEventListener('click', _frostMediaClick, true);
+}).call(undefined);