Move columnizing script

master
Dario Ernst 4 years ago
parent c682d1b479
commit d5958fa60a

1
.gitignore vendored

@ -1,2 +1,3 @@
public/ public/
pdf/ pdf/
public/

@ -1,38 +1,2 @@
<script src="../../js/umbrella.min.js"></script> <script src="../../js/umbrella.min.js"></script>
<script src="../../js/print.js"></script> <script src="../../js/print.js"></script>
<script>
window.addEventListener('load', function () {
const zutatenNode = document.evaluate('//*[@id="zutaten"]', document).iterateNext()
let nodeBlocks = [[]]
let nextNode = zutatenNode.nextElementSibling
while (nextNode && nextNode.tagName != "H2") {
if(nextNode.tagName == 'H4') {
nodeBlocks.push([])
}
nodeBlocks[nodeBlocks.length - 1].push(nextNode)
nextNode = nextNode.nextElementSibling
}
let allIngredientsDiv = document.createElement('div')
allIngredientsDiv.id = "allZutaten"
allIngredientsDiv.classList.add('allZutaten')
let nodeBlockIndex = 0
nodeBlocks.forEach(function(nodeArray) {
let outerDiv = document.createElement('div')
outerDiv.id = `wrap${nodeBlockIndex}`
outerDiv.classList.add("zutatenWrapper")
allIngredientsDiv.appendChild(outerDiv)
for(elem of nodeArray) {
outerDiv.appendChild(elem)
}
nodeBlockIndex += 1
})
zutatenNode.parentNode.insertBefore(allIngredientsDiv, zutatenNode.nextSibling)
console.log("Finished fiddling")
})
</script>

@ -30,3 +30,39 @@ if (hrs.length > 2) {
// Remove the footnote links // Remove the footnote links
u(document.getElementsByClassName('footnote-backref')).remove() u(document.getElementsByClassName('footnote-backref')).remove()
// Break ingredients into column-able blocks
window.addEventListener('load', function () {
const zutatenNode = document.evaluate('//*[@id="zutaten"]', document).iterateNext()
let nodeBlocks = [[]]
let nextNode = zutatenNode.nextElementSibling
while (nextNode && nextNode.tagName != "H2") {
if(nextNode.tagName == 'H4') {
nodeBlocks.push([])
}
nodeBlocks[nodeBlocks.length - 1].push(nextNode)
nextNode = nextNode.nextElementSibling
}
let allIngredientsDiv = document.createElement('div')
allIngredientsDiv.id = "allZutaten"
allIngredientsDiv.classList.add('allZutaten')
let nodeBlockIndex = 0
nodeBlocks.forEach(function(nodeArray) {
let outerDiv = document.createElement('div')
outerDiv.id = `wrap${nodeBlockIndex}`
outerDiv.classList.add("zutatenWrapper")
allIngredientsDiv.appendChild(outerDiv)
for(elem of nodeArray) {
outerDiv.appendChild(elem)
}
nodeBlockIndex += 1
})
zutatenNode.parentNode.insertBefore(allIngredientsDiv, zutatenNode.nextSibling)
console.log("Finished fiddling")
})

Loading…
Cancel
Save