]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/Resources/static/themes/_global/js/tools.js
Added QRCode and link to configure android application
[github/wallabag/wallabag.git] / app / Resources / static / themes / _global / js / tools.js
CommitLineData
c146f694
TC
1const $ = require('jquery');
2
e61ee560
NL
3var jrQrcode = require('jr-qrcode');
4
c146f694
TC
5function supportsLocalStorage() {
6 try {
7 return 'localStorage' in window && window.localStorage !== null;
8 } catch (e) {
9 return false;
10 }
11}
12
13function savePercent(id, percent) {
14 if (!supportsLocalStorage()) { return false; }
15 localStorage[`wallabag.article.${id}.percent`] = percent;
16 return true;
17}
18
19function retrievePercent(id) {
20 if (!supportsLocalStorage()) { return false; }
21
22 const bheight = $(document).height();
23 const percent = localStorage[`wallabag.article.${id}.percent`];
24 const scroll = bheight * percent;
25
26 $('html,body').animate({ scrollTop: scroll }, 'fast');
27
28 return true;
29}
30
31function initFilters() {
32 // no display if filters not available
33 if ($('div').is('#filters')) {
34 $('#button_filters').show();
35 $('.button-collapse-right').sideNav({ edge: 'right' });
36 $('#clear_form_filters').on('click', () => {
37 $('#filters input').val('');
38 $('#filters :checked').removeAttr('checked');
39 return false;
40 });
41 }
42}
43
44function initExport() {
45 // no display if export not available
46 if ($('div').is('#export')) {
47 $('#button_export').show();
48 $('.button-collapse-right').sideNav({ edge: 'right' });
49 }
50}
51
52export { savePercent, retrievePercent, initFilters, initExport };