1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-31 18:31:02 +00:00

Move global tools to material

This commit is contained in:
Yassine Guedidi 2025-01-19 18:25:03 +01:00
parent e63f7ab12e
commit 953f5ee149
3 changed files with 34 additions and 39 deletions

View file

@ -1,36 +0,0 @@
import $ from 'jquery';
import './shortcuts/main';
import './shortcuts/entry';
/* Allows inline call qr-code call */
import jrQrcode from 'jr-qrcode'; // eslint-disable-line
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;
}
function retrievePercent(id, resized) {
if (!supportsLocalStorage()) { return false; }
const bheight = $(document).height();
const percent = localStorage[`wallabag.article.${id}.percent`];
const scroll = bheight * percent;
if (!resized) {
$('html,body').animate({ scrollTop: scroll }, 'fast');
}
return true;
}
export { savePercent, retrievePercent };

View file

@ -22,11 +22,9 @@ import '@fontsource/oswald';
/* Highlight */
import './js/highlight';
import { savePercent, retrievePercent } from '../_global/js/tools';
/* Tools */
import {
initExport, initFilters, initRandom, initPreviewText,
savePercent, retrievePercent, initExport, initFilters, initRandom, initPreviewText,
} from './js/tools';
/* Import shortcuts */

View file

@ -1,5 +1,36 @@
import $ from 'jquery';
/* Allows inline call qr-code call */
import jrQrcode from 'jr-qrcode'; // eslint-disable-line
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;
}
function retrievePercent(id, resized) {
if (!supportsLocalStorage()) { return false; }
const bheight = $(document).height();
const percent = localStorage[`wallabag.article.${id}.percent`];
const scroll = bheight * percent;
if (!resized) {
$('html,body').animate({ scrollTop: scroll }, 'fast');
}
return true;
}
function initFilters() {
// no display if filters not available
if ($('div').is('#filters')) {
@ -46,6 +77,8 @@ function initPreviewText() {
}
export {
savePercent,
retrievePercent,
initExport,
initFilters,
initRandom,