parent
10abd469bc
commit
d65dc16602
@ -1,2 +1,38 @@
|
|||||||
<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>
|
||||||
|
|||||||
Loading…
Reference in new issue