diff options
author | Allan Wang <me@allanwang.ca> | 2018-01-25 00:23:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 00:23:44 -0500 |
commit | 8bfbbac2b8f364bb03866712b113cd2f5de8b9d9 (patch) | |
tree | 8001dd1e467ddd22e4dcec84a9c9e3aa36d2bbb8 /app/src/main/assets/js | |
parent | 6fe7bd43581d5dfbb85e4e0deb524e65d07b5ce6 (diff) | |
download | frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.gz frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.bz2 frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.zip |
Enhancement/video (#669)v1.8.0
* Test stricter video extractor
* Mess around with mutations
* Revert back to strict click listener
* Update theme
* Update dependencies
* Update theme
* Create pip toggle
* Add pip disabler
* Update theme
* Update theme
Diffstat (limited to 'app/src/main/assets/js')
-rw-r--r-- | app/src/main/assets/js/media.coffee | 47 | ||||
-rw-r--r-- | app/src/main/assets/js/media.js | 32 |
2 files changed, 39 insertions, 40 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 diff --git a/app/src/main/assets/js/media.js b/app/src/main/assets/js/media.js index 5ec7f472..5b1a3776 100644 --- a/app/src/main/assets/js/media.js +++ b/app/src/main/assets/js/media.js @@ -5,35 +5,33 @@ var _frostMediaClick; _frostMediaClick = function _frostMediaClick(e) { - /* - * Commonality; check for valid target - */ - var dataStore, element; + var dataStore, element, i, ref, url; element = e.target || e.srcElement; - if (!element.hasAttribute("data-sigil") || !element.getAttribute("data-sigil").toLowerCase().includes("inlinevideo")) { + if (!(element != null ? (ref = element.dataset.sigil) != null ? ref.toLowerCase().includes("inlinevideo") : void 0 : void 0)) { return; } - console.log("Found inline video"); - element = element.parentNode; - if (!element.hasAttribute("data-store")) { - return; + i = 0; + while (!element.hasAttribute("data-store")) { + if (++i > 2) { + return; + } + element = element.parentNode; } - dataStore = void 0; try { - dataStore = JSON.parse(element.getAttribute("data-store")); + dataStore = JSON.parse(element.dataset.store); } catch (error) { e = error; return; } - if (!dataStore.src) { + url = dataStore.src; + if (!url || !url.startsWith("http")) { return; } - console.log("Inline video " + dataStore.src); - if (typeof Frost !== "undefined" && Frost !== null) { - Frost.loadVideo(dataStore.src, dataStore.animatedGifVideo); + console.log("Inline video " + url); + if (typeof Frost !== "undefined" && Frost !== null ? Frost.loadVideo(url, dataStore.animatedGifVideo) : void 0) { + e.stopPropagation(); + e.preventDefault(); } - e.stopPropagation(); - e.preventDefault(); }; document.addEventListener("click", _frostMediaClick, true); |