-const $ = require('jquery');
+import $ from 'jquery';
+import './shortcuts/main';
+import './shortcuts/entry';
-function supportsLocalStorage() {
- try {
- return 'localStorage' in window && window.localStorage !== null;
- } catch (e) {
- return false;
- }
-}
+/* Allows inline call qr-code call */
+import jrQrcode from 'jr-qrcode'; // eslint-disable-line
function savePercent(id, percent) {
- if (!supportsLocalStorage()) { return false; }
- localStorage[`wallabag.article.${id}.percent`] = percent;
- return true;
+ fetch(`/progress/${id}/${percent * 100}`, { credentials: 'include' });
}
-function retrievePercent(id) {
- if (!supportsLocalStorage()) { return false; }
-
- const bheight = $(document).height();
- const percent = localStorage[`wallabag.article.${id}.percent`];
- const scroll = bheight * percent;
+function retrievePercent() {
+ const percent = $('#article').attr('data-progress');
+ console.log(percent);
+ const scroll = $(document).height() * percent;
$('html,body').animate({ scrollTop: scroll }, 'fast');
-
- return true;
}
function initFilters() {
// no display if filters not available
if ($('div').is('#filters')) {
$('#button_filters').show();
- $('.button-collapse-right').sideNav({ edge: 'right' });
+ $('.js-filters-action').sideNav({ edge: 'right' });
$('#clear_form_filters').on('click', () => {
$('#filters input').val('');
$('#filters :checked').removeAttr('checked');
// no display if export not available
if ($('div').is('#export')) {
$('#button_export').show();
- $('.button-collapse-right').sideNav({ edge: 'right' });
+ $('.js-export-action').sideNav({ edge: 'right' });
}
}
-export { savePercent, retrievePercent, initFilters, initExport };
+function throttle(callback, delay) {
+ let last;
+ let timer;
+ return function () {
+ const context = this;
+ const now = new Date();
+ const args = arguments;
+ if (last && now < last + delay) {
+ // le délai n'est pas écoulé on reset le timer
+ clearTimeout(timer);
+ timer = setTimeout(function () {
+ last = now;
+ callback.apply(context, args);
+ }, delay);
+ } else {
+ last = now;
+ callback.apply(context, args);
+ }
+ };
+}
+
+export { savePercent, retrievePercent, initFilters, initExport, throttle };