]>
Commit | Line | Data |
---|---|---|
af61cb80 | 1 | import $ from 'jquery'; |
5637a26e TC |
2 | import './shortcuts/main'; |
3 | import './shortcuts/entry'; | |
c146f694 | 4 | |
32508ef0 TC |
5 | /* Allows inline call qr-code call */ |
6 | import jrQrcode from 'jr-qrcode'; // eslint-disable-line | |
e61ee560 | 7 | |
c146f694 TC |
8 | function supportsLocalStorage() { |
9 | try { | |
10 | return 'localStorage' in window && window.localStorage !== null; | |
11 | } catch (e) { | |
12 | return false; | |
13 | } | |
14 | } | |
15 | ||
16 | function savePercent(id, percent) { | |
17 | if (!supportsLocalStorage()) { return false; } | |
18 | localStorage[`wallabag.article.${id}.percent`] = percent; | |
19 | return true; | |
20 | } | |
21 | ||
f136d288 | 22 | function retrievePercent(id, resized) { |
c146f694 TC |
23 | if (!supportsLocalStorage()) { return false; } |
24 | ||
25 | const bheight = $(document).height(); | |
26 | const percent = localStorage[`wallabag.article.${id}.percent`]; | |
27 | const scroll = bheight * percent; | |
28 | ||
f136d288 S |
29 | if (!resized) { |
30 | $('html,body').animate({ scrollTop: scroll }, 'fast'); | |
31 | } | |
c146f694 TC |
32 | |
33 | return true; | |
34 | } | |
35 | ||
64f81bc3 | 36 | export { savePercent, retrievePercent }; |