mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 12:02:44 +00:00
Remove completely redundant checks for class based exclusion from ToC Snippet
This commit is contained in:
@@ -27,25 +27,12 @@ const getTOC = (pages)=>{
|
|||||||
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
||||||
const headings = iframeDocument.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
const headings = iframeDocument.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||||
const headerDepth = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
const headerDepth = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
||||||
const exclusionElements = iframeDocument.querySelectorAll('frontCover insideCover backCover');
|
|
||||||
const excludedPages = [];
|
|
||||||
|
|
||||||
// Build a list of excluded pages.
|
|
||||||
_.each(exclusionElements, (e)=>{
|
|
||||||
const onPage = parseInt(e.closest('.page,.phb').id?.replace(/^p/, ''));
|
|
||||||
if(!excludedPages.includes(onPage)) excludedPages.push(onPage);
|
|
||||||
});
|
|
||||||
|
|
||||||
_.each(headings, (heading)=>{
|
_.each(headings, (heading)=>{
|
||||||
const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, ''));
|
const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, ''));
|
||||||
const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC');
|
const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC');
|
||||||
|
|
||||||
if(heading.tagName == 'H1') {
|
if(ToCExclude != 'exclude') {
|
||||||
console.log(heading);
|
|
||||||
console.log(ToCExclude);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((ToCExclude != 'exclude') && (!excludedPages.includes(onPage)))) {
|
|
||||||
recursiveAdd(heading.innerText.trim(), onPage, headerDepth.indexOf(heading.tagName), res);
|
recursiveAdd(heading.innerText.trim(), onPage, headerDepth.indexOf(heading.tagName), res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user