]> git.immae.eu Git - github/wallabag/wallabag.git/blob - 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
1 const $ = require('jquery');
2
3 var jrQrcode = require('jr-qrcode');
4
5 function supportsLocalStorage() {
6 try {
7 return 'localStorage' in window && window.localStorage !== null;
8 } catch (e) {
9 return false;
10 }
11 }
12
13 function savePercent(id, percent) {
14 if (!supportsLocalStorage()) { return false; }
15 localStorage[`wallabag.article.${id}.percent`] = percent;
16 return true;
17 }
18
19 function 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
31 function 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
44 function 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
52 export { savePercent, retrievePercent, initFilters, initExport };