diff options
author | Allan Wang <me@allanwang.ca> | 2017-12-10 14:25:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-10 14:25:29 -0500 |
commit | 1d4380cee77fc049a54d280a27dcefa3fa6ff1fd (patch) | |
tree | 6aa222b3f88862a46c8ffd0e46bfb94755d54729 /app/src/main/assets/js | |
parent | 30eb51a44a271512e27c97aecc02f3a339f572bf (diff) | |
download | frost-1d4380cee77fc049a54d280a27dcefa3fa6ff1fd.tar.gz frost-1d4380cee77fc049a54d280a27dcefa3fa6ff1fd.tar.bz2 frost-1d4380cee77fc049a54d280a27dcefa3fa6ff1fd.zip |
theme (#546)
* Update to coffee and use webstorm
* Add chrome as well
* Update all
* Reinstall android 27
Diffstat (limited to 'app/src/main/assets/js')
31 files changed, 593 insertions, 418 deletions
diff --git a/app/src/main/assets/js/click-debugger.js b/app/src/main/assets/js/click-debugger.js deleted file mode 100644 index 702a62c9..00000000 --- a/app/src/main/assets/js/click-debugger.js +++ /dev/null @@ -1,13 +0,0 @@ -//for desktop only -var _frostAContext = function(e) { - /* - * Commonality; check for valid target - */ - var element = e.target || e.currentTarget || e.srcElement; - if (!element) return; - console.log("Clicked element:"); - console.log(element.tagName); - console.log(element.className); -} - -document.addEventListener('contextmenu', _frostAContext, true); diff --git a/app/src/main/assets/js/click-debugger.min.js b/app/src/main/assets/js/click-debugger.min.js deleted file mode 100644 index 0f986b07..00000000 --- a/app/src/main/assets/js/click-debugger.min.js +++ /dev/null @@ -1,6 +0,0 @@ -var _frostAContext=function(e){ -var t=e.target||e.currentTarget||e.srcElement -;t&&(console.log("Clicked element:"), -console.log(t.tagName),console.log(t.className)) -} -;document.addEventListener("contextmenu",_frostAContext,!0);
\ No newline at end of file diff --git a/app/src/main/assets/js/click_a.coffee b/app/src/main/assets/js/click_a.coffee new file mode 100644 index 00000000..e032b4ad --- /dev/null +++ b/app/src/main/assets/js/click_a.coffee @@ -0,0 +1,48 @@ +prevented = false + +_frostAClick = (e) -> + + ### + # Commonality; check for valid target + ### + element = e.target or e.srcElement + if element.tagName != "A" + element = element.parentNode + # Notifications is two layers under + if element.tagName != "A" + element = element.parentNode + if element.tagName == "A" + if !prevented + url = element.getAttribute("href") + console.log "Click Intercept #{url}" + # if frost is injected, check if loading the url through an overlay works + if Frost?.loadUrl(url) == true + e.stopPropagation() + e.preventDefault() + else + console.log "Click Intercept Prevented" + return + +### +# On top of the click event, we must stop it for long presses +# Since that will conflict with the context menu +# Note that we only override it on conditions where the context menu +# Will occur +### + +_frostPreventClick = -> + console.log "Click prevented" + prevented = true + return + +document.addEventListener "click", _frostAClick, true +clickTimeout = undefined +document.addEventListener "touchstart", ((e) -> + clickTimeout = setTimeout(_frostPreventClick, 400) + return +), true +document.addEventListener "touchend", ((e) -> + prevented = false + clearTimeout clickTimeout + return +), true diff --git a/app/src/main/assets/js/click_a.js b/app/src/main/assets/js/click_a.js index 1ced820a..e3ea7f31 100644 --- a/app/src/main/assets/js/click_a.js +++ b/app/src/main/assets/js/click_a.js @@ -1,57 +1,60 @@ -// we will handle click events -if (!window.hasOwnProperty('frost_click_a')) { - console.log('Registering frost_click_a'); - window.frost_click_a = true; +"use strict"; - var prevented = false; +(function () { - var _frostAClick = function(e) { + /* + * On top of the click event, we must stop it for long presses + * Since that will conflict with the context menu + * Note that we only override it on conditions where the context menu + * Will occur + */ + var _frostAClick, _frostPreventClick, clickTimeout, prevented; + prevented = false; + _frostAClick = function _frostAClick(e) { /* * Commonality; check for valid target */ - var element = e.target || e.srcElement; - - if (element.tagName !== 'A') element = element.parentNode; - //Notifications is two layers under - if (element.tagName !== 'A') element = element.parentNode; - if (element.tagName === 'A') { + var element, url; + element = e.target || e.srcElement; + if (element.tagName !== "A") { + element = element.parentNode; + } + // Notifications is two layers under + if (element.tagName !== "A") { + element = element.parentNode; + } + if (element.tagName === "A") { if (!prevented) { - var url = element.getAttribute('href'); - console.log('Click Intercept', url); + url = element.getAttribute("href"); + console.log("Click Intercept " + url); // if frost is injected, check if loading the url through an overlay works - if (typeof Frost !== 'undefined' && Frost.loadUrl(url)) { - e.stopPropagation(); - e.preventDefault(); + if ((typeof Frost !== "undefined" && Frost !== null ? Frost.loadUrl(url) : void 0) === true) { + e.stopPropagation(); + e.preventDefault(); } } else { - console.log('Click Intercept Prevented'); + console.log("Click Intercept Prevented"); } } - } + }; - /* - * On top of the click event, we must stop it for long presses - * Since that will conflict with the context menu - * Note that we only override it on conditions where the context menu - * Will occur - */ - var _frostPreventClick = function() { - console.log('Click prevented') + _frostPreventClick = function _frostPreventClick() { + console.log("Click prevented"); prevented = true; - } + }; - document.addEventListener('click', _frostAClick, true); + document.addEventListener("click", _frostAClick, true); - var clickTimeout; + clickTimeout = void 0; - document.addEventListener('touchstart', function _frostStart(e) { + document.addEventListener("touchstart", function (e) { clickTimeout = setTimeout(_frostPreventClick, 400); }, true); - document.addEventListener('touchend', function _frostEnd(e) { + document.addEventListener("touchend", function (e) { prevented = false; clearTimeout(clickTimeout); }, true); -} +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/click_a.min.js b/app/src/main/assets/js/click_a.min.js deleted file mode 100644 index 7abaaac6..00000000 --- a/app/src/main/assets/js/click_a.min.js +++ /dev/null @@ -1,22 +0,0 @@ -if(!window.hasOwnProperty("frost_click_a")){ -console.log("Registering frost_click_a"), -window.frost_click_a=!0 -;var prevented=!1,_frostAClick=function(e){ -var t=e.target||e.srcElement -;if("A"!==t.tagName&&(t=t.parentNode),"A"!==t.tagName&&(t=t.parentNode), -"A"===t.tagName)if(prevented)console.log("Click Intercept Prevented");else{ -var o=t.getAttribute("href") -;console.log("Click Intercept",o),"undefined"!=typeof Frost&&Frost.loadUrl(o)&&(e.stopPropagation(), -e.preventDefault()) -} -},_frostPreventClick=function(){ -console.log("Click prevented"),prevented=!0 -} -;document.addEventListener("click",_frostAClick,!0) -;var clickTimeout -;document.addEventListener("touchstart",function(e){ -clickTimeout=setTimeout(_frostPreventClick,400) -},!0),document.addEventListener("touchend",function(e){ -prevented=!1,clearTimeout(clickTimeout) -},!0) -}
\ No newline at end of file diff --git a/app/src/main/assets/js/click_debugger.coffee b/app/src/main/assets/js/click_debugger.coffee new file mode 100644 index 00000000..057bb207 --- /dev/null +++ b/app/src/main/assets/js/click_debugger.coffee @@ -0,0 +1,14 @@ +# for desktop only + +_frostAContext = (e) -> + + ### + # Commonality; check for valid target + ### + element = e.target or e.currentTarget or e.srcElement + if !element + return + console.log "Clicked element: #{element.tagName} #{element.className}" + return + +document.addEventListener 'contextmenu', _frostAContext, true diff --git a/app/src/main/assets/js/click_debugger.js b/app/src/main/assets/js/click_debugger.js new file mode 100644 index 00000000..71db586a --- /dev/null +++ b/app/src/main/assets/js/click_debugger.js @@ -0,0 +1,20 @@ +'use strict'; + +(function () { + // for desktop only + var _frostAContext; + + _frostAContext = function _frostAContext(e) { + /* + * Commonality; check for valid target + */ + var element; + element = e.target || e.currentTarget || e.srcElement; + if (!element) { + return; + } + console.log('Clicked element: ' + element.tagName + ' ' + element.className); + }; + + document.addEventListener('contextmenu', _frostAContext, true); +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/context_a.coffee b/app/src/main/assets/js/context_a.coffee new file mode 100644 index 00000000..0dca1b7f --- /dev/null +++ b/app/src/main/assets/js/context_a.coffee @@ -0,0 +1,59 @@ +# context menu for links +# largely mimics click_a.js +# we will also bind a listener here to notify the activity not to deal with viewpager scrolls +longClick = false + +_frostAContext = (e) -> + Frost?.longClick true + longClick = true + + ### + # Commonality; check for valid target + ### + + element = e.target or e.currentTarget or e.srcElement + if !element + return + if element.tagName != "A" + element = element.parentNode + #Notifications is two layers under + if element.tagName != "A" + element = element.parentNode + if element.tagName == "A" and element.getAttribute("href") != "#" + url = element.getAttribute("href") + if !url + return + text = element.parentNode.innerText + # check if image item exists, first in children and then in parent + image = element.querySelector("[style*=\"background-image: url(\"]") + if !image + image = element.parentNode.querySelector("[style*=\"background-image: url(\"]") + if image + imageUrl = window.getComputedStyle(image, null).backgroundImage.trim().slice(4, -1) + console.log "Context image: #{imageUrl}" + Frost?.loadImage imageUrl, text + e.stopPropagation() + e.preventDefault() + return + # check if true img exists + img = element.querySelector("img[src*=scontent]") + if img + imgUrl = img.src + console.log "Context img #{imgUrl}" + Frost?.loadImage imgUrl, text + e.stopPropagation() + e.preventDefault() + return + console.log "Context Content #{url} #{text}" + Frost?.contextMenu url, text + e.stopPropagation() + e.preventDefault() + return + +document.addEventListener "contextmenu", _frostAContext, true +document.addEventListener "touchend", ((e) -> + if longClick + Frost?.longClick false + longClick = false + return +), true diff --git a/app/src/main/assets/js/context_a.js b/app/src/main/assets/js/context_a.js index dfc75a80..b39a6542 100644 --- a/app/src/main/assets/js/context_a.js +++ b/app/src/main/assets/js/context_a.js @@ -1,67 +1,83 @@ -//context menu for links -//largely mimics click_a.js -//we will also bind a listener here to notify the activity not to deal with viewpager scrolls -//since the long press is also associated witho -if (!window.hasOwnProperty('frost_context_a')) { - console.log('frost_context_a frost_click_a'); - window.frost_context_a = true; +"use strict"; - var longClick = false; +(function () { + // context menu for links + // largely mimics click_a.js + // we will also bind a listener here to notify the activity not to deal with viewpager scrolls + var _frostAContext, longClick; - var _frostAContext = function(e) { - if (typeof Frost !== 'undefined') Frost.longClick(true); - longClick = true; + longClick = false; + _frostAContext = function _frostAContext(e) { /* * Commonality; check for valid target */ - var element = e.target || e.currentTarget || e.srcElement; - if (!element) return; - if (element.tagName !== 'A') element = element.parentNode; + var element, image, imageUrl, img, imgUrl, text, url; + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.longClick(true); + } + longClick = true; + element = e.target || e.currentTarget || e.srcElement; + if (!element) { + return; + } + if (element.tagName !== "A") { + element = element.parentNode; + } //Notifications is two layers under - if (element.tagName !== 'A') element = element.parentNode; - if (element.tagName === 'A' && element.getAttribute('href') !== '#') { - var url = element.getAttribute('href'); - if (!url) return; - var text = element.parentNode.innerText; - - //check if image item exists, first in children and then in parent - var image = element.querySelector('[style*="background-image: url("]'); - if (!image) image = element.parentNode.querySelector('[style*="background-image: url("]'); + if (element.tagName !== "A") { + element = element.parentNode; + } + if (element.tagName === "A" && element.getAttribute("href") !== "#") { + url = element.getAttribute("href"); + if (!url) { + return; + } + text = element.parentNode.innerText; + // check if image item exists, first in children and then in parent + image = element.querySelector("[style*=\"background-image: url(\"]"); + if (!image) { + image = element.parentNode.querySelector("[style*=\"background-image: url(\"]"); + } if (image) { - var imageUrl = window.getComputedStyle(image, null).backgroundImage.trim().slice(4, -1); - console.log('Context image: ' + imageUrl); - if (typeof Frost !== 'undefined') Frost.loadImage(imageUrl, text); + imageUrl = window.getComputedStyle(image, null).backgroundImage.trim().slice(4, -1); + console.log("Context image: " + imageUrl); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.loadImage(imageUrl, text); + } e.stopPropagation(); e.preventDefault(); return; } - - //check if true img exists - var img = element.querySelector('img[src*=scontent]') + // check if true img exists + img = element.querySelector("img[src*=scontent]"); if (img) { - var imgUrl = img.src; - console.log('Context img', imgUrl); - if (typeof Frost !== 'undefined') Frost.loadImage(imgUrl, text); + imgUrl = img.src; + console.log("Context img " + imgUrl); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.loadImage(imgUrl, text); + } e.stopPropagation(); e.preventDefault(); return; } - - console.log('Context Content', url, text); - if (typeof Frost !== 'undefined') Frost.contextMenu(url, text); - + console.log("Context Content " + url + " " + text); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.contextMenu(url, text); + } e.stopPropagation(); e.preventDefault(); } - } + }; - document.addEventListener('contextmenu', _frostAContext, true); + document.addEventListener("contextmenu", _frostAContext, true); - document.addEventListener('touchend', function _frostEnd(e) { + document.addEventListener("touchend", function (e) { if (longClick) { - if (typeof Frost !== 'undefined') Frost.longClick(false); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.longClick(false); + } longClick = false; } }, true); -} +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/context_a.min.js b/app/src/main/assets/js/context_a.min.js deleted file mode 100644 index 260b41ff..00000000 --- a/app/src/main/assets/js/context_a.min.js +++ /dev/null @@ -1,36 +0,0 @@ -if(!window.hasOwnProperty("frost_context_a")){ -console.log("frost_context_a frost_click_a"), -window.frost_context_a=!0 -;var longClick=!1,_frostAContext=function(e){ -"undefined"!=typeof Frost&&Frost.longClick(!0), -longClick=!0 -;var t=e.target||e.currentTarget||e.srcElement -;if(t&&("A"!==t.tagName&&(t=t.parentNode), -"A"!==t.tagName&&(t=t.parentNode),"A"===t.tagName&&"#"!==t.getAttribute("href"))){ -var o=t.getAttribute("href") -;if(!o)return -;var n=t.parentNode.innerText,r=t.querySelector('[style*="background-image: url("]') -;if(r||(r=t.parentNode.querySelector('[style*="background-image: url("]')), -r){ -var a=window.getComputedStyle(r,null).backgroundImage.trim().slice(4,-1) -;return console.log("Context image: "+a), -"undefined"!=typeof Frost&&Frost.loadImage(a,n), -e.stopPropagation(),void e.preventDefault() -} -var i=t.querySelector("img[src*=scontent]") -;if(i){ -var l=i.src -;return console.log("Context img",l),"undefined"!=typeof Frost&&Frost.loadImage(l,n), -e.stopPropagation(), -void e.preventDefault() -} -console.log("Context Content",o,n),"undefined"!=typeof Frost&&Frost.contextMenu(o,n), -e.stopPropagation(), -e.preventDefault() -} -} -;document.addEventListener("contextmenu",_frostAContext,!0),document.addEventListener("touchend",function(e){ -longClick&&("undefined"!=typeof Frost&&Frost.longClick(!1), -longClick=!1) -},!0) -}
\ No newline at end of file diff --git a/app/src/main/assets/js/header_badges.coffee b/app/src/main/assets/js/header_badges.coffee new file mode 100644 index 00000000..e9702751 --- /dev/null +++ b/app/src/main/assets/js/header_badges.coffee @@ -0,0 +1,4 @@ +# bases the header contents if it exists +header = document.getElementById("mJewelNav") +if header != null + Frost?.handleHeader header.outerHTML diff --git a/app/src/main/assets/js/header_badges.js b/app/src/main/assets/js/header_badges.js index 26315a5f..13447229 100644 --- a/app/src/main/assets/js/header_badges.js +++ b/app/src/main/assets/js/header_badges.js @@ -1,3 +1,14 @@ -//bases the header contents if it exists -var header = document.getElementById('mJewelNav'); -if (header !== null) Frost.handleHeader(header.outerHTML); +"use strict"; + +(function () { + // bases the header contents if it exists + var header; + + header = document.getElementById("mJewelNav"); + + if (header !== null) { + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.handleHeader(header.outerHTML); + } + } +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/header_badges.min.js b/app/src/main/assets/js/header_badges.min.js deleted file mode 100644 index 7d5b45ea..00000000 --- a/app/src/main/assets/js/header_badges.min.js +++ /dev/null @@ -1,2 +0,0 @@ -var header=document.getElementById("mJewelNav"); -if(header!==null)Frost.handleHeader(header.outerHTML);
\ No newline at end of file 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 + diff --git a/app/src/main/assets/js/media.js b/app/src/main/assets/js/media.js index f1a5ac3c..5ec7f472 100644 --- a/app/src/main/assets/js/media.js +++ b/app/src/main/assets/js/media.js @@ -1,31 +1,40 @@ -// we will media events -if (!window.hasOwnProperty('frost_media')) { - console.log('Registering frost_media'); - window.frost_media = true; +"use strict"; - var _frostMediaClick = function(e) { +(function () { + // we will handle media events + var _frostMediaClick; + _frostMediaClick = function _frostMediaClick(e) { /* * Commonality; check for valid target */ - var element = e.target || e.srcElement; - if (!element.hasAttribute("data-sigil") || !element.getAttribute("data-sigil").toLowerCase().includes("inlinevideo")) return; + 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; - var dataStore; + if (!element.hasAttribute("data-store")) { + return; + } + dataStore = void 0; try { dataStore = JSON.parse(element.getAttribute("data-store")); - } catch (e) { + } catch (error) { + e = error; + return; + } + if (!dataStore.src) { return; } - if (!dataStore.src) return; console.log("Inline video " + dataStore.src); - if (typeof Frost !== 'undefined') Frost.loadVideo(dataStore.src, dataStore.animatedGifVideo); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.loadVideo(dataStore.src, dataStore.animatedGifVideo); + } e.stopPropagation(); e.preventDefault(); - return; - } + }; - document.addEventListener('click', _frostMediaClick, true); -} + document.addEventListener("click", _frostMediaClick, true); +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/media.min.js b/app/src/main/assets/js/media.min.js deleted file mode 100644 index 767b8a36..00000000 --- a/app/src/main/assets/js/media.min.js +++ /dev/null @@ -1,21 +0,0 @@ -if(!window.hasOwnProperty("frost_media")){ -console.log("Registering frost_media"), -window.frost_media=!0 -;var _frostMediaClick=function(e){ -var t=e.target||e.srcElement -;if(t.hasAttribute("data-sigil")&&t.getAttribute("data-sigil").toLowerCase().includes("inlinevideo")&&(console.log("Found inline video"), -t=t.parentNode, -t.hasAttribute("data-store"))){ -var i -;try{ -i=JSON.parse(t.getAttribute("data-store")) -}catch(e){ -return -} -i.src&&(console.log("Inline video "+i.src),"undefined"!=typeof Frost&&Frost.loadVideo(i.src,i.animatedGifVideo), -e.stopPropagation(), -e.preventDefault()) -} -} -;document.addEventListener("click",_frostMediaClick,!0) -}
\ No newline at end of file diff --git a/app/src/main/assets/js/menu.coffee b/app/src/main/assets/js/menu.coffee new file mode 100644 index 00000000..8072eeab --- /dev/null +++ b/app/src/main/assets/js/menu.coffee @@ -0,0 +1,42 @@ +# click menu and move contents to main view +viewport = document.querySelector("#viewport") +root = document.querySelector("#root") +if !viewport + console.log "Menu.js: viewport is null" +if !root + console.log "Menu.js: root is null" +y = new MutationObserver((mutations) -> + viewport.removeAttribute "style" + root.removeAttribute "style" + return +) +y.observe viewport, attributes: true +y.observe root, attributes: true +x = new MutationObserver((mutations) -> + menu = document.querySelector(".mSideMenu") + if menu != null + x.disconnect() + console.log "Found side menu" + while root.firstChild + root.removeChild root.firstChild + while menu.childNodes.length + console.log "append" + viewport.appendChild menu.childNodes[0] + Frost?.emit 0 + setTimeout (-> + y.disconnect() + console.log "Unhook styler" + return + ), 500 + return +) +jewel = document.querySelector("#mJewelNav") +if !jewel + console.log "Menu.js: jewel is null" +x.observe jewel, + childList: true + subtree: true +menuA = document.querySelector("#bookmarks_jewel").querySelector("a") +if !menuA + console.log "Menu.js: jewel is null" +menuA.click()
\ No newline at end of file diff --git a/app/src/main/assets/js/menu.js b/app/src/main/assets/js/menu.js index a43b1820..49534c7e 100644 --- a/app/src/main/assets/js/menu.js +++ b/app/src/main/assets/js/menu.js @@ -1,46 +1,73 @@ -//click menu and move contents to main view -if (!window.hasOwnProperty('frost_menu')) { - console.log('Registering frost_menu'); - window.frost_menu = true; - var viewport = document.querySelector('#viewport'); - var root = document.querySelector('#root'); - if (!viewport) console.log('Menu.js: viewport is null'); - if (!root) console.log('Menu.js: root is null'); - var y = new MutationObserver(function(mutations) { - viewport.removeAttribute('style'); - root.removeAttribute('style'); +"use strict"; + +(function () { + // click menu and move contents to main view + var jewel, menuA, root, viewport, x, y; + + viewport = document.querySelector("#viewport"); + + root = document.querySelector("#root"); + + if (!viewport) { + console.log("Menu.js: viewport is null"); + } + + if (!root) { + console.log("Menu.js: root is null"); + } + + y = new MutationObserver(function (mutations) { + viewport.removeAttribute("style"); + root.removeAttribute("style"); }); + y.observe(viewport, { attributes: true }); + y.observe(root, { attributes: true }); - var x = new MutationObserver(function(mutations) { - var menu = document.querySelector('.mSideMenu'); + + x = new MutationObserver(function (mutations) { + var menu; + menu = document.querySelector(".mSideMenu"); if (menu !== null) { x.disconnect(); - console.log('Found side menu'); - while (root.firstChild) + console.log("Found side menu"); + while (root.firstChild) { root.removeChild(root.firstChild); + } while (menu.childNodes.length) { - console.log('append'); + console.log("append"); viewport.appendChild(menu.childNodes[0]); } - if (typeof Frost !== 'undefined') Frost.emit(0); - setTimeout(function() { + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.emit(0); + } + setTimeout(function () { y.disconnect(); - console.log('Unhook styler'); + console.log("Unhook styler"); }, 500); } }); - var jewel = document.querySelector('#mJewelNav'); - if (!jewel) console.log('Menu.js: jewel is null'); + + jewel = document.querySelector("#mJewelNav"); + + if (!jewel) { + console.log("Menu.js: jewel is null"); + } + x.observe(jewel, { childList: true, subtree: true }); - var menuA = document.querySelector('#bookmarks_jewel').querySelector('a'); - if (!menuA) console.log('Menu.js: jewel is null') + + menuA = document.querySelector("#bookmarks_jewel").querySelector("a"); + + if (!menuA) { + console.log("Menu.js: jewel is null"); + } + menuA.click(); -} +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/menu.min.js b/app/src/main/assets/js/menu.min.js deleted file mode 100644 index 5b65ac9b..00000000 --- a/app/src/main/assets/js/menu.min.js +++ /dev/null @@ -1,33 +0,0 @@ -if(!window.hasOwnProperty("frost_menu")){ -console.log("Registering frost_menu"),window.frost_menu=!0 -;var viewport=document.querySelector("#viewport"),root=document.querySelector("#root") -;viewport||console.log("Menu.js: viewport is null"), -root||console.log("Menu.js: root is null") -;var y=new MutationObserver(function(e){ -viewport.removeAttribute("style"),root.removeAttribute("style") -}) -;y.observe(viewport,{ -attributes:!0 -}),y.observe(root,{ -attributes:!0 -}) -;var x=new MutationObserver(function(e){ -var o=document.querySelector(".mSideMenu") -;if(null!==o){ -for(x.disconnect(),console.log("Found side menu");root.firstChild;)root.removeChild(root.firstChild) -;for(;o.childNodes.length;)console.log("append"), -viewport.appendChild(o.childNodes[0]) -;"undefined"!=typeof Frost&&Frost.emit(0),setTimeout(function(){ -y.disconnect(),console.log("Unhook styler") -},500) -} -}),jewel=document.querySelector("#mJewelNav") -;jewel||console.log("Menu.js: jewel is null"), -x.observe(jewel,{ -childList:!0, -subtree:!0 -}) -;var menuA=document.querySelector("#bookmarks_jewel").querySelector("a") -;menuA||console.log("Menu.js: jewel is null"), -menuA.click() -}
\ No newline at end of file diff --git a/app/src/main/assets/js/menu_debug.coffee b/app/src/main/assets/js/menu_debug.coffee new file mode 100644 index 00000000..54b265f4 --- /dev/null +++ b/app/src/main/assets/js/menu_debug.coffee @@ -0,0 +1,42 @@ +# click menu and move contents to main view +viewport = document.querySelector("#viewport") +root = document.querySelector("#root") +if !viewport + console.log "Menu.js: viewport is null" +if !root + console.log "Menu.js: root is null" +y = new MutationObserver((mutations) -> + viewport.removeAttribute "style" + root.removeAttribute "style" + return +) +y.observe viewport, attributes: true +y.observe root, attributes: true +x = new MutationObserver((mutations) -> + menu = document.querySelector(".mSideMenu") + if menu != null + x.disconnect() + console.log "Found side menu" + while root.firstChild + root.removeChild root.firstChild + while menu.childNodes.length + console.log "append" + viewport.appendChild menu.childNodes[0] + Frost?.handleHtml viewport.outerHTML + setTimeout (-> + y.disconnect() + console.log "Unhook styler" + return + ), 500 + return +) +jewel = document.querySelector("#mJewelNav") +if !jewel + console.log "Menu.js: jewel is null" +x.observe jewel, + childList: true + subtree: true +menuA = document.querySelector("#bookmarks_jewel").querySelector("a") +if !menuA + console.log "Menu.js: jewel is null" +menuA.click() diff --git a/app/src/main/assets/js/menu_debug.js b/app/src/main/assets/js/menu_debug.js index 552dc909..7ecbf276 100644 --- a/app/src/main/assets/js/menu_debug.js +++ b/app/src/main/assets/js/menu_debug.js @@ -1,46 +1,73 @@ -//click menu and move contents to main view -if (!window.hasOwnProperty('frost_menu')) { - console.log('Registering frost_menu'); - window.frost_menu = true; - var viewport = document.querySelector('#viewport'); - var root = document.querySelector('#root'); - if (!viewport) console.log('Menu.js: viewport is null'); - if (!root) console.log('Menu.js: root is null'); - var y = new MutationObserver(function(mutations) { - viewport.removeAttribute('style'); - root.removeAttribute('style'); +"use strict"; + +(function () { + // click menu and move contents to main view + var jewel, menuA, root, viewport, x, y; + + viewport = document.querySelector("#viewport"); + + root = document.querySelector("#root"); + + if (!viewport) { + console.log("Menu.js: viewport is null"); + } + + if (!root) { + console.log("Menu.js: root is null"); + } + + y = new MutationObserver(function (mutations) { + viewport.removeAttribute("style"); + root.removeAttribute("style"); }); + y.observe(viewport, { attributes: true }); + y.observe(root, { attributes: true }); - var x = new MutationObserver(function(mutations) { - var menu = document.querySelector('.mSideMenu'); + + x = new MutationObserver(function (mutations) { + var menu; + menu = document.querySelector(".mSideMenu"); if (menu !== null) { x.disconnect(); - console.log('Found side menu'); - while (root.firstChild) + console.log("Found side menu"); + while (root.firstChild) { root.removeChild(root.firstChild); + } while (menu.childNodes.length) { - console.log('append'); + console.log("append"); viewport.appendChild(menu.childNodes[0]); } - if (typeof Frost !== 'undefined') Frost.handleHtml(viewport.outerHTML); - setTimeout(function() { + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.handleHtml(viewport.outerHTML); + } + setTimeout(function () { y.disconnect(); - console.log('Unhook styler'); + console.log("Unhook styler"); }, 500); } }); - var jewel = document.querySelector('#mJewelNav'); - if (!jewel) console.log('Menu.js: jewel is null'); + + jewel = document.querySelector("#mJewelNav"); + + if (!jewel) { + console.log("Menu.js: jewel is null"); + } + x.observe(jewel, { childList: true, subtree: true }); - var menuA = document.querySelector('#bookmarks_jewel').querySelector('a'); - if (!menuA) console.log('Menu.js: jewel is null') + + menuA = document.querySelector("#bookmarks_jewel").querySelector("a"); + + if (!menuA) { + console.log("Menu.js: jewel is null"); + } + menuA.click(); -} +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/menu_debug.min.js b/app/src/main/assets/js/menu_debug.min.js deleted file mode 100644 index df51c13b..00000000 --- a/app/src/main/assets/js/menu_debug.min.js +++ /dev/null @@ -1,34 +0,0 @@ -if(!window.hasOwnProperty("frost_menu")){ -console.log("Registering frost_menu"),window.frost_menu=!0 -;var viewport=document.querySelector("#viewport"),root=document.querySelector("#root") -;viewport||console.log("Menu.js: viewport is null"), -root||console.log("Menu.js: root is null") -;var y=new MutationObserver(function(e){ -viewport.removeAttribute("style"),root.removeAttribute("style") -}) -;y.observe(viewport,{ -attributes:!0 -}),y.observe(root,{ -attributes:!0 -}) -;var x=new MutationObserver(function(e){ -var o=document.querySelector(".mSideMenu") -;if(null!==o){ -for(x.disconnect(),console.log("Found side menu");root.firstChild;)root.removeChild(root.firstChild) -;for(;o.childNodes.length;)console.log("append"), -viewport.appendChild(o.childNodes[0]) -;"undefined"!=typeof Frost&&Frost.handleHtml(viewport.outerHTML), -setTimeout(function(){ -y.disconnect(),console.log("Unhook styler") -},500) -} -}),jewel=document.querySelector("#mJewelNav") -;jewel||console.log("Menu.js: jewel is null"), -x.observe(jewel,{ -childList:!0, -subtree:!0 -}) -;var menuA=document.querySelector("#bookmarks_jewel").querySelector("a") -;menuA||console.log("Menu.js: jewel is null"), -menuA.click() -}
\ No newline at end of file diff --git a/app/src/main/assets/js/notif_msg.coffee b/app/src/main/assets/js/notif_msg.coffee new file mode 100644 index 00000000..1c3f8e38 --- /dev/null +++ b/app/src/main/assets/js/notif_msg.coffee @@ -0,0 +1,22 @@ +# binds callbacks to an invisible webview to take in the search events +finished = false +x = new MutationObserver((mutations) -> + _f_thread = document.querySelector("#threadlist_rows") + if !_f_thread + return + console.log "Found message threads #{_f_thread.outerHTML}" + Frost?.handleHtml _f_thread.outerHTML + finished = true + x.disconnect() + return +) +x.observe document, + childList: true + subtree: true +setTimeout (-> + if !finished + finished = true + console.log "Message thread timeout cancellation" + Frost?.handleHtml "" + return +), 20000 diff --git a/app/src/main/assets/js/notif_msg.js b/app/src/main/assets/js/notif_msg.js index 83405f39..134ad4f0 100644 --- a/app/src/main/assets/js/notif_msg.js +++ b/app/src/main/assets/js/notif_msg.js @@ -1,25 +1,37 @@ -//binds callbacks to an invisible webview to take in the search events -if (!window.hasOwnProperty('frost_notif_msg')) { - console.log('Registering frost_notif_msg'); - window.frost_notif_msg = true; - var finished = false; - var x = new MutationObserver(function(mutations) { - var _f_thread = document.querySelector('#threadlist_rows'); - if (!_f_thread) return; - console.log('Found message threads', _f_thread.outerHTML); - if (typeof Frost !== 'undefined') Frost.handleHtml(_f_thread.outerHTML); +"use strict"; + +(function () { + // binds callbacks to an invisible webview to take in the search events + var finished, x; + + finished = false; + + x = new MutationObserver(function (mutations) { + var _f_thread; + _f_thread = document.querySelector("#threadlist_rows"); + if (!_f_thread) { + return; + } + console.log("Found message threads " + _f_thread.outerHTML); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.handleHtml(_f_thread.outerHTML); + } finished = true; x.disconnect(); }); + x.observe(document, { childList: true, subtree: true }); - setTimeout(function() { + + setTimeout(function () { if (!finished) { finished = true; - console.log('Message thread timeout cancellation') - if (typeof Frost !== 'undefined') Frost.handleHtml(""); + console.log("Message thread timeout cancellation"); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.handleHtml(""); + } } }, 20000); -} +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/notif_msg.min.js b/app/src/main/assets/js/notif_msg.min.js deleted file mode 100644 index cb965d02..00000000 --- a/app/src/main/assets/js/notif_msg.min.js +++ /dev/null @@ -1,17 +0,0 @@ -if(!window.hasOwnProperty("frost_notif_msg")){ -console.log("Registering frost_notif_msg"), -window.frost_notif_msg=!0 -;var finished=!1,x=new MutationObserver(function(e){ -var o=document.querySelector("#threadlist_rows") -;o&&(console.log("Found message threads",o.outerHTML), -"undefined"!=typeof Frost&&Frost.handleHtml(o.outerHTML), -finished=!0,x.disconnect()) -}) -;x.observe(document,{ -childList:!0, -subtree:!0 -}),setTimeout(function(){ -finished||(finished=!0,console.log("Message thread timeout cancellation"), -"undefined"!=typeof Frost&&Frost.handleHtml("")) -},2e4) -}
\ No newline at end of file diff --git a/app/src/main/assets/js/search.js b/app/src/main/assets/js/search.js deleted file mode 100644 index 0a8954ef..00000000 --- a/app/src/main/assets/js/search.js +++ /dev/null @@ -1,19 +0,0 @@ -//binds callbacks to an invisible webview to take in the search events -if (!window.hasOwnProperty('frost_search')) { - console.log('Registering frost_search'); - window.frost_search = true; - var _f_page = document.querySelector('#page'); - // var _f_input = document.querySelector('#main-search-input') - if (!_f_page) Frost.emit(1); - else { - Frost.emit(0); - var x = new MutationObserver(function(mutations) { - Frost.handleHtml(page.innerHTML); - Frost.emit(2); - }); - x.observe(_f_page, { - childList: true, - subtree: true - }); - } -} diff --git a/app/src/main/assets/js/search.min.js b/app/src/main/assets/js/search.min.js deleted file mode 100644 index 109bfb13..00000000 --- a/app/src/main/assets/js/search.min.js +++ /dev/null @@ -1,15 +0,0 @@ -if(!window.hasOwnProperty("frost_search")){ -console.log("Registering frost_search"), -window.frost_search=!0 -;var _f_page=document.querySelector("#page") -;if(_f_page){ -Frost.emit(0) -;var x=new MutationObserver(function(e){ -Frost.handleHtml(page.innerHTML),Frost.emit(2) -}) -;x.observe(_f_page,{ -childList:!0, -subtree:!0 -}) -}else Frost.emit(1) -}
\ No newline at end of file diff --git a/app/src/main/assets/js/search_query.js b/app/src/main/assets/js/search_query.js deleted file mode 100644 index 806519de..00000000 --- a/app/src/main/assets/js/search_query.js +++ /dev/null @@ -1,10 +0,0 @@ -var e = document.getElementById('main-search-input'); -if (e) { - e.value = '$input'; - var n = new Event('input', { - bubbles: !0, - cancelable: !0 - }); - e.dispatchEvent(n); - e.dispatchEvent(new Event('focus')); -} else console.log('Input field not found') diff --git a/app/src/main/assets/js/textarea_listener.coffee b/app/src/main/assets/js/textarea_listener.coffee new file mode 100644 index 00000000..950f663e --- /dev/null +++ b/app/src/main/assets/js/textarea_listener.coffee @@ -0,0 +1,22 @@ +# focus listener for textareas +# since swipe to refresh is quite sensitive, we will disable it +# when we detect a user typing +# note that this extends passed having a keyboard opened, +# as a user may still be reviewing his/her post +# swiping should automatically be reset on refresh + +_frostFocus = (e) -> + element = e.target or e.srcElement + console.log "Frost focus", element.tagName + if element.tagName == "TEXTAREA" + Frost?.disableSwipeRefresh true + return + +_frostBlur = (e) -> + element = e.target or e.srcElement + console.log "Frost blur", element.tagName + Frost?.disableSwipeRefresh false + return + +document.addEventListener "focus", _frostFocus, true +document.addEventListener "blur", _frostBlur, true diff --git a/app/src/main/assets/js/textarea_listener.js b/app/src/main/assets/js/textarea_listener.js index e6951411..41d77159 100644 --- a/app/src/main/assets/js/textarea_listener.js +++ b/app/src/main/assets/js/textarea_listener.js @@ -1,27 +1,35 @@ -//focus listener for textareas -//since swipe to refresh is quite sensitive, we will disable it -//when we detect a user typing -//note that this extends passed having a keyboard opened, -//as a user may still be reviewing his/her post -//swiping should automatically be reset on refresh -if (!window.hasOwnProperty('frost_textarea_listener')) { - console.log('Registering frost_textarea_listener'); - window.frost_textarea_listener = true; +"use strict"; - var _frostFocus = function(e) { - var element = e.target || e.srcElement; - console.log('Frost focus', element.tagName); - if (element.tagName === 'TEXTAREA') - if (typeof Frost !== 'undefined') Frost.disableSwipeRefresh(true); - } +(function () { + // focus listener for textareas + // since swipe to refresh is quite sensitive, we will disable it + // when we detect a user typing + // note that this extends passed having a keyboard opened, + // as a user may still be reviewing his/her post + // swiping should automatically be reset on refresh + var _frostBlur, _frostFocus; - var _frostBlur = function(e) { - var element = e.target || e.srcElement; - console.log('Frost blur', element.tagName); - if (typeof Frost !== 'undefined') Frost.disableSwipeRefresh(false); - } + _frostFocus = function _frostFocus(e) { + var element; + element = e.target || e.srcElement; + console.log("Frost focus", element.tagName); + if (element.tagName === "TEXTAREA") { + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.disableSwipeRefresh(true); + } + } + }; - document.addEventListener('focus', _frostFocus, true); - document.addEventListener('blur', _frostBlur, true); + _frostBlur = function _frostBlur(e) { + var element; + element = e.target || e.srcElement; + console.log("Frost blur", element.tagName); + if (typeof Frost !== "undefined" && Frost !== null) { + Frost.disableSwipeRefresh(false); + } + }; -} + document.addEventListener("focus", _frostFocus, true); + + document.addEventListener("blur", _frostBlur, true); +}).call(undefined);
\ No newline at end of file diff --git a/app/src/main/assets/js/textarea_listener.min.js b/app/src/main/assets/js/textarea_listener.min.js deleted file mode 100644 index 44ae9ceb..00000000 --- a/app/src/main/assets/js/textarea_listener.min.js +++ /dev/null @@ -1,12 +0,0 @@ -if(!window.hasOwnProperty("frost_textarea_listener")){ -console.log("Registering frost_textarea_listener"), -window.frost_textarea_listener=!0 -;var _frostFocus=function(e){ -var t=e.target||e.srcElement -;console.log("Frost focus",t.tagName),"TEXTAREA"===t.tagName&&"undefined"!=typeof Frost&&Frost.disableSwipeRefresh(!0) -},_frostBlur=function(e){ -var t=e.target||e.srcElement -;console.log("Frost blur",t.tagName),"undefined"!=typeof Frost&&Frost.disableSwipeRefresh(!1) -} -;document.addEventListener("focus",_frostFocus,!0),document.addEventListener("blur",_frostBlur,!0) -}
\ No newline at end of file |