mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
Move a couple of variables back out of the global space because that was bad.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
const _ = require('lodash');
|
||||
const dedent = require('dedent-tabs').default;
|
||||
|
||||
const res = [];
|
||||
|
||||
const pageMap = [];
|
||||
|
||||
const walkPages = (iframeDocument)=>{
|
||||
const walkPages = (iframeDocument, pageMap)=>{
|
||||
let current = 0;
|
||||
let skip = 0;
|
||||
let reset = 0;
|
||||
@@ -54,12 +50,15 @@ const recursiveAdd = (title, page, actualPage, targetDepth, child, curDepth=0)=>
|
||||
|
||||
|
||||
const getTOC = ()=>{
|
||||
const pageMap = [];
|
||||
const res = [];
|
||||
|
||||
const iframe = document.getElementById('BrewRenderer');
|
||||
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
||||
const headings = iframeDocument.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||
const headerDepth = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
||||
|
||||
walkPages(iframeDocument);
|
||||
walkPages(iframeDocument, pageMap);
|
||||
|
||||
_.each(headings, (heading)=>{
|
||||
const onPage = parseInt(heading.closest('.page').id?.replace(/^p/, ''));
|
||||
|
||||
Reference in New Issue
Block a user