]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/Resources/static/themes/_global/js/restoreScroll.js
Merge pull request #2309 from mruminski/2.1
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / js / restoreScroll.js
CommitLineData
19f2f11e 1function supportsLocalStorage() {
0743287f
TC
2 try {
3 return 'localStorage' in window && window.localStorage !== null;
4 } catch (e) {
5 return false;
6 }
19f2f11e
NL
7}
8
9function savePercent(id, percent) {
0743287f
TC
10 if (!supportsLocalStorage()) { return false; }
11 localStorage['wallabag.article.' + id + '.percent'] = percent;
12 return true;
19f2f11e
NL
13}
14
15function retrievePercent(id) {
0743287f 16 if (!supportsLocalStorage()) { return false; }
19f2f11e 17
0743287f
TC
18 var bheight = $(document).height();
19 var percent = localStorage['wallabag.article.' + id + '.percent'];
20 var scroll = bheight * percent;
19f2f11e 21
0743287f 22 $('html,body').animate({ scrollTop: scroll }, 'fast');
19f2f11e 23
0743287f 24 return true;
5ecdfcd0 25}