aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.js
blob: 5ec7f472ecc073e9d431eaffdcc860eb071ac96b (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
39
40
"use strict";

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

  _frostMediaClick = function _frostMediaClick(e) {
    /*
     * Commonality; check for valid target
     */
    var dataStore, element;
    element = e.target || e.srcElement;
    if (!element.hasAttribute("data-sigil") || !element.getAttribute("data-sigil").toLowerCase().includes("inlinevideo")) {
      return;
    }
    console.log("Found inline video");
    element = element.parentNode;
    if (!element.hasAttribute("data-store")) {
      return;
    }
    dataStore = void 0;
    try {
      dataStore = JSON.parse(element.getAttribute("data-store"));
    } catch (error) {
      e = error;
      return;
    }
    if (!dataStore.src) {
      return;
    }
    console.log("Inline video " + dataStore.src);
    if (typeof Frost !== "undefined" && Frost !== null) {
      Frost.loadVideo(dataStore.src, dataStore.animatedGifVideo);
    }
    e.stopPropagation();
    e.preventDefault();
  };

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