From f2a441061bb5b96d3b90faa580d2ea2b5fb1266f Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 15 Jan 2017 17:23:19 +0800 Subject: Fix checkLoginStateChanged might fall into infinite loop while calling loginStateChangeEvent --- public/js/common.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'public/js') diff --git a/public/js/common.js b/public/js/common.js index f5bfc8ec..7eee1071 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -18,7 +18,8 @@ var checkAuth = false; var profile = null; var lastLoginState = getLoginState(); var lastUserId = getUserId(); -var loginStateChangeEvent = null; + +window.loginStateChangeEvent = null; function resetCheckAuth() { checkAuth = false; @@ -42,8 +43,7 @@ function setLoginState(bool, id) { function checkLoginStateChanged() { if (getLoginState() != lastLoginState || getUserId() != lastUserId) { - if(loginStateChangeEvent) - loginStateChangeEvent(); + if(loginStateChangeEvent) setTimeout(loginStateChangeEvent, 100); return true; } else { return false; @@ -65,8 +65,7 @@ function clearLoginState() { function checkIfAuth(yesCallback, noCallback) { var cookieLoginState = getLoginState(); - if (checkLoginStateChanged()) - checkAuth = false; + if (checkLoginStateChanged()) checkAuth = false; if (!checkAuth || typeof cookieLoginState == 'undefined') { $.get(serverurl + '/me') .done(function (data) { @@ -107,7 +106,6 @@ module.exports = { profile: profile, lastLoginState: lastLoginState, lastUserId: lastUserId, - loginStateChangeEvent: loginStateChangeEvent, /* export functions */ resetCheckAuth: resetCheckAuth, -- cgit v1.2.3 From 5751578275bd505ea613c77ab997a6ee29b1c1ee Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 15 Jan 2017 17:23:33 +0800 Subject: Update to remove history pagination animation on refresh --- public/js/cover.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'public/js') diff --git a/public/js/cover.js b/public/js/cover.js index a8d8ecfe..15f3e9c1 100644 --- a/public/js/cover.js +++ b/public/js/cover.js @@ -355,7 +355,6 @@ $(".ui-refresh-history").click(function () { $('.search').val(''); historyList.search(); $('#history-list').slideUp('fast'); - $('.pagination').slideUp('fast'); resetCheckAuth(); historyList.clear(); @@ -367,7 +366,6 @@ $(".ui-refresh-history").click(function () { $('.search').val(lastKeyword); checkHistoryList(); $('#history-list').slideDown('fast'); - $('.pagination').slideDown('fast'); }); }); -- cgit v1.2.3 From f2ee8976997906f76fae39a5f5d7f70860f2c8dc Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 16 Jan 2017 12:04:11 +0800 Subject: Fix to prevent hash change on click nav item on index --- public/js/cover.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'public/js') diff --git a/public/js/cover.js b/public/js/cover.js index 15f3e9c1..7c63e912 100644 --- a/public/js/cover.js +++ b/public/js/cover.js @@ -91,14 +91,18 @@ $(".masthead-nav li").click(function () { $(this).addClass("active"); }); -$(".ui-home").click(function () { +$(".ui-home").click(function (e) { + e.preventDefault(); + e.stopPropagation(); if (!$("#home").is(':visible')) { $(".section:visible").hide(); $("#home").fadeIn(); } }); -$(".ui-history").click(function () { +$(".ui-history").click(function (e) { + e.preventDefault(); + e.stopPropagation(); if (!$("#history").is(':visible')) { $(".section:visible").hide(); $("#history").fadeIn(); -- cgit v1.2.3 From 091e7271e0e7e5df83516c471af34f4ae481d12a Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 16 Jan 2017 12:24:40 +0800 Subject: Fix pagination should hide on refresh history --- public/js/cover.js | 1 + 1 file changed, 1 insertion(+) (limited to 'public/js') diff --git a/public/js/cover.js b/public/js/cover.js index 7c63e912..52ff5a27 100644 --- a/public/js/cover.js +++ b/public/js/cover.js @@ -359,6 +359,7 @@ $(".ui-refresh-history").click(function () { $('.search').val(''); historyList.search(); $('#history-list').slideUp('fast'); + $('.pagination').hide(); resetCheckAuth(); historyList.clear(); -- cgit v1.2.3 From e00daee6c0dd0c6e5f2654d24995bc9d86fbc452 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 16 Jan 2017 12:42:21 +0800 Subject: Update to prevent all empty link change hash --- public/js/cover.js | 9 +++++---- public/js/index.js | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'public/js') diff --git a/public/js/cover.js b/public/js/cover.js index 52ff5a27..f8ffe9bf 100644 --- a/public/js/cover.js +++ b/public/js/cover.js @@ -91,9 +91,12 @@ $(".masthead-nav li").click(function () { $(this).addClass("active"); }); -$(".ui-home").click(function (e) { +// prevent empty link change hash +$('a[href="#"]').click(function (e) { e.preventDefault(); - e.stopPropagation(); +}); + +$(".ui-home").click(function (e) { if (!$("#home").is(':visible')) { $(".section:visible").hide(); $("#home").fadeIn(); @@ -101,8 +104,6 @@ $(".ui-home").click(function (e) { }); $(".ui-history").click(function (e) { - e.preventDefault(); - e.stopPropagation(); if (!$("#history").is(':visible')) { $(".section:visible").hide(); $("#history").fadeIn(); diff --git a/public/js/index.js b/public/js/index.js index 14235bc3..a018e513 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1754,6 +1754,10 @@ ui.toolbar.uploadImage.bind('change', function (e) { ui.toc.dropdown.click(function (e) { e.stopPropagation(); }); +// prevent empty link change hash +$('a[href="#"]').click(function (e) { + e.preventDefault(); +}); //modal actions var revisions = []; -- cgit v1.2.3