]>
Commit | Line | Data |
---|---|---|
1 | const $ = require('jquery'); | |
2 | ||
3 | /* Allows inline call qr-code call */ | |
4 | import jrQrcode from 'jr-qrcode'; // eslint-disable-line | |
5 | ||
6 | function supportsLocalStorage() { | |
7 | try { | |
8 | return 'localStorage' in window && window.localStorage !== null; | |
9 | } catch (e) { | |
10 | return false; | |
11 | } | |
12 | } | |
13 | ||
14 | function savePercent(id, percent) { | |
15 | if (!supportsLocalStorage()) { return false; } | |
16 | localStorage[`wallabag.article.${id}.percent`] = percent; | |
17 | return true; | |
18 | } | |
19 | ||
20 | function retrievePercent(id) { | |
21 | if (!supportsLocalStorage()) { return false; } | |
22 | ||
23 | const bheight = $(document).height(); | |
24 | const percent = localStorage[`wallabag.article.${id}.percent`]; | |
25 | const scroll = bheight * percent; | |
26 | ||
27 | $('html,body').animate({ scrollTop: scroll }, 'fast'); | |
28 | ||
29 | return true; | |
30 | } | |
31 | ||
32 | function initFilters() { | |
33 | // no display if filters not available | |
34 | if ($('div').is('#filters')) { | |
35 | $('#button_filters').show(); | |
36 | $('.button-collapse-right').sideNav({ edge: 'right' }); | |
37 | $('#clear_form_filters').on('click', () => { | |
38 | $('#filters input').val(''); | |
39 | $('#filters :checked').removeAttr('checked'); | |
40 | return false; | |
41 | }); | |
42 | } | |
43 | } | |
44 | ||
45 | function initExport() { | |
46 | // no display if export not available | |
47 | if ($('div').is('#export')) { | |
48 | $('#button_export').show(); | |
49 | $('.button-collapse-right').sideNav({ edge: 'right' }); | |
50 | } | |
51 | } | |
52 | ||
53 | export { savePercent, retrievePercent, initFilters, initExport }; |