diff options
author | Thedro Neely <thedroneely@gmail.com> | 2020-09-28 01:30:41 -0400 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2020-09-28 01:30:41 -0400 |
commit | 08fbb453887f6bb1d6044d5da83b8b47ed9fc73f (patch) | |
tree | 93d7d8dc81f63185ac52d9f5e2ce667aced077e2 /public/js/app.js | |
parent | 97f0f974e9e76593ce141b04e573936c93421877 (diff) | |
download | thedroneely.com-08fbb453887f6bb1d6044d5da83b8b47ed9fc73f.tar.gz thedroneely.com-08fbb453887f6bb1d6044d5da83b8b47ed9fc73f.tar.bz2 thedroneely.com-08fbb453887f6bb1d6044d5da83b8b47ed9fc73f.zip |
public/js/app: Pager store urls without hash
Diffstat (limited to 'public/js/app.js')
-rw-r--r-- | public/js/app.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/public/js/app.js b/public/js/app.js index a4a40ce..7e4c120 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -14,21 +14,30 @@ function togClass (el, cl) { if (hasClass(el, cl)) { remClass(el, cl); return; } function runOnce(action) { runOnce = function(){}; action(); } /** - * Remove url query string on load + * Remove url query string */ var url = window.location.href.split('?')[0]; window.history.replaceState(null, null, url); /** + * Remove url hash to store in pager + */ +var url = window.location.href.split('#')[0]; + +/** * Settings array */ var settings = { pager: {} }; window.addEventListener('load', function(event) { - if (url.indexOf("#") >= 0) { return; } if (localStorage['settings']) { settings = JSON.parse(localStorage['settings']); } + if (window.location.href.indexOf("#") >= 0) { + settings['pager'][url] = window.pageYOffset + 1; + localStorage['settings'] = JSON.stringify(settings); + return; + } if (settings['pager'][url]) { window.scrollTo(0, settings['pager'][url]); return; } - settings['pager'][url] = 1; + settings['pager'][url] = window.pageYOffset + 1; localStorage['settings'] = JSON.stringify(settings); }); |