]>
Commit | Line | Data |
---|---|---|
19f2f11e | 1 | function supportsLocalStorage() { |
0743287f TC |
2 | try { |
3 | return 'localStorage' in window && window.localStorage !== null; | |
4 | } catch (e) { | |
5 | return false; | |
6 | } | |
19f2f11e NL |
7 | } |
8 | ||
9 | function savePercent(id, percent) { | |
0743287f TC |
10 | if (!supportsLocalStorage()) { return false; } |
11 | localStorage['wallabag.article.' + id + '.percent'] = percent; | |
12 | return true; | |
19f2f11e NL |
13 | } |
14 | ||
15 | function 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 | } |