aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-06 19:26:38 -0400
committerGitHub <noreply@github.com>2017-07-06 19:26:38 -0400
commitbb70ed737d98abbd6164b66ac5bd667553b312bd (patch)
tree1899d7adefe3fbf67e6fd26a4da0837898bd6d7a /app/src/main/assets
parent2586e947f769740dd8cb8bf8b1dd0473b51e50e4 (diff)
downloadfrost-bb70ed737d98abbd6164b66ac5bd667553b312bd.tar.gz
frost-bb70ed737d98abbd6164b66ac5bd667553b312bd.tar.bz2
frost-bb70ed737d98abbd6164b66ac5bd667553b312bd.zip
Dev 1.1.5 - JS fixes & sharing intents (#32)v1.1.5
* Add sharing intents * Fix up multiple js instances
Diffstat (limited to 'app/src/main/assets')
-rw-r--r--app/src/main/assets/js/click_a.js32
-rw-r--r--app/src/main/assets/js/click_a.min.js29
-rw-r--r--app/src/main/assets/js/click_interceptor.js13
-rw-r--r--app/src/main/assets/js/click_interceptor.min.js17
-rw-r--r--app/src/main/assets/js/header_badges.min.js5
-rw-r--r--app/src/main/assets/js/menu.js73
-rw-r--r--app/src/main/assets/js/menu.min.js10
-rw-r--r--app/src/main/assets/js/search.js33
-rw-r--r--app/src/main/assets/js/search.min.js15
9 files changed, 121 insertions, 106 deletions
diff --git a/app/src/main/assets/js/click_a.js b/app/src/main/assets/js/click_a.js
index a960c4f2..aabcd7e3 100644
--- a/app/src/main/assets/js/click_a.js
+++ b/app/src/main/assets/js/click_a.js
@@ -1,18 +1,22 @@
// we will handle click events
-console.log('Registering frost_a click');
+if (!window.hasOwnProperty('frost_click_a')) {
+ console.log('Registering frost_click_a');
+ window.frost_click_a = true;
-var _frostAClick = function(e) {
- 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' && element.getAttribute('href') !== '#') {
- var url = element.getAttribute('href');
- console.log('Click Intercept', url);
- Frost.loadUrl(url);
- e.stopPropagation();
- e.preventDefault();
+ var _frostAClick = function(e) {
+ 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' && element.getAttribute('href') !== '#') {
+ var url = element.getAttribute('href');
+ if (url.includes('photoset_token')) return;
+ console.log('Click Intercept', url);
+ Frost.loadUrl(url);
+ e.stopPropagation();
+ e.preventDefault();
+ }
}
-}
-document.addEventListener('click', _frostAClick, true);
+ document.addEventListener('click', _frostAClick, true);
+}
diff --git a/app/src/main/assets/js/click_a.min.js b/app/src/main/assets/js/click_a.min.js
index d858d956..b09e7174 100644
--- a/app/src/main/assets/js/click_a.min.js
+++ b/app/src/main/assets/js/click_a.min.js
@@ -1,12 +1,17 @@
-console.log("Registering frost_a click")
-
-;var _frostAClick=function(t){
-var e=t.target||t.srcElement
-;if("A"!==e.tagName&&(e=e.parentNode),"A"!==e.tagName&&(e=e.parentNode),
-"A"===e.tagName&&"#"!==e.getAttribute("href")){
-var r=e.getAttribute("href")
-;console.log("Click Intercept",r),Frost.loadUrl(r),t.stopPropagation(),
-t.preventDefault()
-}
-}
-;document.addEventListener("click",_frostAClick,!0); \ No newline at end of file
+if(!window.hasOwnProperty("frost_click_a")){
+console.log("Registering frost_click_a");
+window.frost_click_a=true;
+var _frostAClick=function(e){
+var element=e.target||e.srcElement;
+if(element.tagName!=="A")element=element.parentNode;
+if(element.tagName!=="A")element=element.parentNode;
+if(element.tagName==="A"&&element.getAttribute("href")!=="#"){
+var url=element.getAttribute("href");
+if(url.includes("photoset_token"))return;
+console.log("Click Intercept",url);
+Frost.loadUrl(url);
+e.stopPropagation();
+e.preventDefault();
+}};
+document.addEventListener("click",_frostAClick,true);
+} \ No newline at end of file
diff --git a/app/src/main/assets/js/click_interceptor.js b/app/src/main/assets/js/click_interceptor.js
index ce55f669..debf85dc 100644
--- a/app/src/main/assets/js/click_interceptor.js
+++ b/app/src/main/assets/js/click_interceptor.js
@@ -1,6 +1,9 @@
// we will handle click events
-console.log('Registering click interceptor');
-document.addEventListener('click', function _menuClick(e) {
- var element = e.target || e.srcElement;
- console.log(element.tagName);
-}, true);
+if (!window.hasOwnProperty('frost_click_interceptor')) {
+ console.log('Registering frost_click_interceptor');
+ window.frost_click_interceptor = true;
+ document.addEventListener('click', function _menuClick(e) {
+ var element = e.target || e.srcElement;
+ console.log(element.tagName);
+ }, true);
+}
diff --git a/app/src/main/assets/js/click_interceptor.min.js b/app/src/main/assets/js/click_interceptor.min.js
index 3acb9265..45649781 100644
--- a/app/src/main/assets/js/click_interceptor.min.js
+++ b/app/src/main/assets/js/click_interceptor.min.js
@@ -1,9 +1,8 @@
-document.querySelector("body").addEventListener("click",function(e){
-e=e||window.event
-;var t=e.target||e.srcElement
-;if("A"!==t.tagName&&(t=t.parentNode),"A"===t.tagName){
-var n=t.href
-;console.log("Generic Click Intercept"),console.log(n)
-}
-return!1
-}); \ No newline at end of file
+if(!window.hasOwnProperty("frost_click_interceptor")){
+console.log("Registering frost_click_interceptor");
+window.frost_click_interceptor=true;
+document.addEventListener("click",function _menuClick(e){
+var element=e.target||e.srcElement;
+console.log(element.tagName);
+},true);
+} \ 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
index 9526474d..7d5b45ea 100644
--- a/app/src/main/assets/js/header_badges.min.js
+++ b/app/src/main/assets/js/header_badges.min.js
@@ -1,3 +1,2 @@
-var header=document.getElementById("mJewelNav")
-
-;null!==header&&Frost.handleHeader(header.outerHTML); \ No newline at end of file
+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/menu.js b/app/src/main/assets/js/menu.js
index 458d9edf..f8cd03c9 100644
--- a/app/src/main/assets/js/menu.js
+++ b/app/src/main/assets/js/menu.js
@@ -1,36 +1,39 @@
//click menu and move contents to main view
-console.log('Fetching menu');
-var viewport = document.querySelector('#viewport');
-var root = document.querySelector('#root');
-var 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');
- if (menu !== null) {
- x.disconnect();
- console.log('Found side menu');
- while (root.firstChild)
- root.removeChild(root.firstChild);
- while (menu.childNodes.length)
- root.appendChild(menu.childNodes[0]);
- Frost.emit(0);
- setTimeout(function() {
- y.disconnect();
- console.log('Unhook styler');
- Frost.handleHtml(document.documentElement.outerHTML);
- }, 500);
- }
-});
-x.observe(document.querySelector('#mJewelNav'), {
- childList: true,
- subtree: true
-});
-document.querySelector('#bookmarks_jewel').querySelector('a').click();
+if (!window.hasOwnProperty('frost_menu')) {
+ console.log('Registering frost_menu');
+ window.frost_menu = true;
+ var viewport = document.querySelector('#viewport');
+ var root = document.querySelector('#root');
+ var 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');
+ if (menu !== null) {
+ x.disconnect();
+ console.log('Found side menu');
+ while (root.firstChild)
+ root.removeChild(root.firstChild);
+ while (menu.childNodes.length)
+ root.appendChild(menu.childNodes[0]);
+ Frost.emit(0);
+ setTimeout(function() {
+ y.disconnect();
+ console.log('Unhook styler');
+ Frost.handleHtml(document.documentElement.outerHTML);
+ }, 500);
+ }
+ });
+ x.observe(document.querySelector('#mJewelNav'), {
+ childList: true,
+ subtree: true
+ });
+ document.querySelector('#bookmarks_jewel').querySelector('a').click();
+}
diff --git a/app/src/main/assets/js/menu.min.js b/app/src/main/assets/js/menu.min.js
index 4627b847..ce878b88 100644
--- a/app/src/main/assets/js/menu.min.js
+++ b/app/src/main/assets/js/menu.min.js
@@ -1,16 +1,14 @@
-console.log("Fetching menu")
-
+if(!window.hasOwnProperty("frost_menu")){
+console.log("Registering frost_menu"),window.frost_menu=!0
;var viewport=document.querySelector("#viewport"),root=document.querySelector("#root"),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){
@@ -22,8 +20,8 @@ Frost.handleHtml(document.documentElement.outerHTML)
},500)
}
})
-
;x.observe(document.querySelector("#mJewelNav"),{
childList:!0,
subtree:!0
-}),document.querySelector("#bookmarks_jewel").querySelector("a").click(); \ No newline at end of file
+}),document.querySelector("#bookmarks_jewel").querySelector("a").click()
+} \ No newline at end of file
diff --git a/app/src/main/assets/js/search.js b/app/src/main/assets/js/search.js
index 5f0f0e0a..0a8954ef 100644
--- a/app/src/main/assets/js/search.js
+++ b/app/src/main/assets/js/search.js
@@ -1,16 +1,19 @@
//binds callbacks to an invisible webview to take in the search events
-console.log('Binding Search');
-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
- });
-// }
+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
index c5e577d1..109bfb13 100644
--- a/app/src/main/assets/js/search.min.js
+++ b/app/src/main/assets/js/search.min.js
@@ -1,14 +1,15 @@
-console.log("Binding Search")
-
+if(!window.hasOwnProperty("frost_search")){
+console.log("Registering frost_search"),
+window.frost_search=!0
;var _f_page=document.querySelector("#page")
-
-;_f_page||Frost.emit(1),Frost.emit(0)
-
+;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
-}); \ No newline at end of file
+})
+}else Frost.emit(1)
+} \ No newline at end of file