Skip to content

Commit 78ea526

Browse files
committed
Fix positioning of examples in folders
1 parent 309dfe4 commit 78ea526

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@
505505
structure[parts[1]].children.push(parts[2])
506506
}
507507
}
508-
const buildRow = async (fileName) => {
508+
const buildRow = async (fileName, insertAfterRow = null) => {
509509
response = await fetch(`examples/${fileName}`)
510510
let turtle = await response.text()
511511
let details = await getDetailsFromGraphTurtle(turtle)
@@ -520,7 +520,12 @@
520520
td = document.createElement("td")
521521
td.appendChild(buildActionSpan("Load", () => loadTurtle(turtle)))
522522
tr.appendChild(td)
523-
table.appendChild(tr)
523+
if (insertAfterRow && insertAfterRow.parentNode === table) {
524+
table.insertBefore(tr, insertAfterRow.nextSibling)
525+
} else {
526+
table.appendChild(tr)
527+
}
528+
return tr
524529
}
525530
for (let key of Object.keys(structure)) {
526531
if (key === "ROOT") {
@@ -537,8 +542,9 @@
537542
td.addEventListener("click", async () => {
538543
if (structure[key].expanded) return
539544
structure[key].expanded = true
545+
let lastRow = tr
540546
for (let child of structure[key].children) {
541-
await buildRow(`${key}/${child}`)
547+
lastRow = await buildRow(`${key}/${child}`, lastRow)
542548
}
543549
})
544550
tr.appendChild(td)

0 commit comments

Comments
 (0)