Build & save injection order values
This commit is contained in:
parent
1bc84bbb49
commit
bd117b8fd7
|
@ -54,7 +54,10 @@ function onRuntimeMessage(msg) {
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setTimeout(sorter.updateStripes, 0, {onlyWhenColumnsChanged: true});
|
setTimeout(() => {
|
||||||
|
sorter.updateStripes({onlyWhenColumnsChanged: true});
|
||||||
|
updateInjectionOrder();
|
||||||
|
}, 0, );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -395,6 +398,7 @@ function handleDelete(id) {
|
||||||
btnApply.dataset.value = Number(btnApply.dataset.value) - 1;
|
btnApply.dataset.value = Number(btnApply.dataset.value) - 1;
|
||||||
}
|
}
|
||||||
showFiltersStats();
|
showFiltersStats();
|
||||||
|
updateInjectionOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,18 +491,18 @@ function removeSelection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInjectionOrder() {
|
function updateInjectionOrder() {
|
||||||
|
if (installed.dataset.sort === 'order') {
|
||||||
const entries = [...installed.children];
|
const entries = [...installed.children];
|
||||||
entries.shift(); // remove header
|
entries.shift(); // remove header
|
||||||
// console.log(entries[1].styleMeta.id, entries[1].styleMeta.injectionOrder)
|
|
||||||
|
|
||||||
entries.forEach((entry, index) => {
|
entries.forEach((entry, index) => {
|
||||||
entry.styleMeta.injectionOrder = index + 1;
|
entry.styleMeta.injectionOrder = index + 1;
|
||||||
$('.entry-id', entry).textContent = index + 1;
|
$('.entry-id', entry).textContent = index + 1;
|
||||||
|
UI.injectionXref[entry.styleMeta.id] = index + 1;
|
||||||
});
|
});
|
||||||
sorter.update();
|
sorter.update();
|
||||||
|
|
||||||
// TODO: Update database
|
// TODO: Update database
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function lazyLoad() {
|
function lazyLoad() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -17,6 +17,8 @@ const UI = {
|
||||||
faviconsGray: prefs.get('manage.newUI.faviconsGray'),
|
faviconsGray: prefs.get('manage.newUI.faviconsGray'),
|
||||||
targets: prefs.get('manage.newUI.targets'),
|
targets: prefs.get('manage.newUI.targets'),
|
||||||
|
|
||||||
|
injectionXref: {},
|
||||||
|
|
||||||
labels: {
|
labels: {
|
||||||
'usercss': {
|
'usercss': {
|
||||||
is: ({style}) => typeof style.usercssData !== 'undefined',
|
is: ({style}) => typeof style.usercssData !== 'undefined',
|
||||||
|
@ -44,6 +46,18 @@ const UI = {
|
||||||
|
|
||||||
showStyles: (styles = [], matchUrlIds) => {
|
showStyles: (styles = [], matchUrlIds) => {
|
||||||
UI.addHeaderLabels();
|
UI.addHeaderLabels();
|
||||||
|
|
||||||
|
// map injection order of styles
|
||||||
|
if (styles && styles.length && !styles.every(s => s.injectionOrder)) {
|
||||||
|
UI.injectionXref = styles
|
||||||
|
.sort((a, b) => ((a.injectionOrder || a.id) - (b.injectionOrder || b.id)))
|
||||||
|
.map((s, index) => (s.injectionOrder = index + 1))
|
||||||
|
.reduce((acc, s) => {
|
||||||
|
acc[s.id] = s.injectionOrder;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
const sorted = sorter.sort({
|
const sorted = sorter.sort({
|
||||||
styles: styles.map(style => ({
|
styles: styles.map(style => ({
|
||||||
style,
|
style,
|
||||||
|
@ -138,7 +152,7 @@ const UI = {
|
||||||
(style.updateUrl ? ' updatable' : '') +
|
(style.updateUrl ? ' updatable' : '') +
|
||||||
(style.usercssData ? ' usercss' : '');
|
(style.usercssData ? ' usercss' : '');
|
||||||
|
|
||||||
$('.entry-id', entry).textContent = style.injectionOrder || style.id;
|
$('.entry-id', entry).textContent = style.injectionOrder || UI.injectionXref[style.id];
|
||||||
let el = $('.entry-homepage', entry);
|
let el = $('.entry-homepage', entry);
|
||||||
el.classList.toggle('invisible', !style.url);
|
el.classList.toggle('invisible', !style.url);
|
||||||
el.href = style.url || '';
|
el.href = style.url || '';
|
||||||
|
|
|
@ -120,6 +120,7 @@ a:hover {
|
||||||
100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); }
|
100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.entry-header a:hover .svg-icon,
|
||||||
.entry a:hover .svg-icon,
|
.entry a:hover .svg-icon,
|
||||||
.svg-icon:hover {
|
.svg-icon:hover {
|
||||||
fill: var(--entry-icon-hover-color);
|
fill: var(--entry-icon-hover-color);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user