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