aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.js
blob: 5b1a3776c52a1d5b833c76def052a8b1abe61de6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";

(function () {
  // we will handle media events
  var _frostMediaClick;

  _frostMediaClick = function _frostMediaClick(e) {
    var dataStore, element, i, ref, url;
    element = e.target || e.srcElement;
    if (!(element != null ? (ref = element.dataset.sigil) != null ? ref.toLowerCase().includes("inlinevideo") : void 0 : void 0)) {
      return;
    }
    i = 0;
    while (!element.hasAttribute("data-store")) {
      if (++i > 2) {
        return;
      }
      element = element.parentNode;
    }
    try {
      dataStore = JSON.parse(element.dataset.store);
    } catch (error) {
      e = error;
      return;
    }
    url = dataStore.src;
    if (!url || !url.startsWith("http")) {
      return;
    }
    console.log("Inline video " + url);
    if (typeof Frost !== "undefined" && Frost !== null ? Frost.loadVideo(url, dataStore.animatedGifVideo) : void 0) {
      e.stopPropagation();
      e.preventDefault();
    }
  };

  document.addEventListener("click", _frostMediaClick, true);
}).call(undefined);