2016-10-27 01:57:27 +02:00
|
|
|
import $ from 'jquery';
|
2016-11-03 10:02:16 +01:00
|
|
|
import './shortcuts/main';
|
|
|
|
import './shortcuts/entry';
|
2016-09-28 10:30:18 +02:00
|
|
|
|
2016-11-03 14:23:09 +01:00
|
|
|
/* Allows inline call qr-code call */
|
|
|
|
import jrQrcode from 'jr-qrcode'; // eslint-disable-line
|
2016-10-31 16:16:41 +01:00
|
|
|
|
2016-09-28 10:30:18 +02:00
|
|
|
function supportsLocalStorage() {
|
|
|
|
try {
|
|
|
|
return 'localStorage' in window && window.localStorage !== null;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function savePercent(id, percent) {
|
|
|
|
if (!supportsLocalStorage()) { return false; }
|
|
|
|
localStorage[`wallabag.article.${id}.percent`] = percent;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-05-24 08:27:15 +02:00
|
|
|
function retrievePercent(id, resized) {
|
2016-09-28 10:30:18 +02:00
|
|
|
if (!supportsLocalStorage()) { return false; }
|
|
|
|
|
|
|
|
const bheight = $(document).height();
|
|
|
|
const percent = localStorage[`wallabag.article.${id}.percent`];
|
|
|
|
const scroll = bheight * percent;
|
|
|
|
|
2018-05-24 08:27:15 +02:00
|
|
|
if (!resized) {
|
|
|
|
$('html,body').animate({ scrollTop: scroll }, 'fast');
|
|
|
|
}
|
2016-09-28 10:30:18 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-31 20:21:41 +02:00
|
|
|
export { savePercent, retrievePercent };
|