titlepath is titles not ids
parent
a544b2c7cf
commit
02173a7bbe
|
|
@ -119,6 +119,7 @@ crawl_with() {
|
||||||
full_title="${full_title#/}"
|
full_title="${full_title#/}"
|
||||||
export TITLE="${full_title##*/}"
|
export TITLE="${full_title##*/}"
|
||||||
export CONTENT="$(
|
export CONTENT="$(
|
||||||
|
echo "**!! WARNING !! This page is autogenerated and prone to destruction and replacement**"
|
||||||
$backend get "$crawlable_source" "$i"
|
$backend get "$crawlable_source" "$i"
|
||||||
)"
|
)"
|
||||||
export ID="$(
|
export ID="$(
|
||||||
|
|
|
||||||
|
|
@ -226,8 +226,9 @@
|
||||||
pids = pids.slice(0, pids.length-1)
|
pids = pids.slice(0, pids.length-1)
|
||||||
|
|
||||||
var titlePath = "/"
|
var titlePath = "/"
|
||||||
for (var pid in pids) {
|
for (var i = 0; i < pids.length; i++) {
|
||||||
titlePath += ` <input type="button" class="lil_btn" value="${pids[pid]}" onclick="drawFile('${pids.slice(0, pid+1).join("/")}');"/> /`
|
const fullPid = pids.slice(0, i+1)
|
||||||
|
titlePath += ` <input type="button" class="lil_btn" value="${idsToTitle(fullPid)}" onclick="drawFile('${fullPid.join("/")}');"/> /`
|
||||||
}
|
}
|
||||||
|
|
||||||
enableMDE()
|
enableMDE()
|
||||||
|
|
@ -266,6 +267,23 @@
|
||||||
navigateToQueryParams()
|
navigateToQueryParams()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lastTree = {}
|
||||||
|
|
||||||
|
function idsToTitle(original_ids) {
|
||||||
|
var ids = original_ids.slice(0, original_ids.length)
|
||||||
|
var subtree = lastTree
|
||||||
|
while (ids && ids.length > 0) {
|
||||||
|
if (!subtree || !subtree["Branches"] || !subtree["Branches"][ids[0]])
|
||||||
|
break
|
||||||
|
subtree = subtree["Branches"][ids[0]]
|
||||||
|
ids = ids.slice(1, ids.length)
|
||||||
|
if (ids.length == 0 && subtree.Leaf && subtree.Leaf.Title ) {
|
||||||
|
return subtree.Leaf.Title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ids[ids.length-1]
|
||||||
|
}
|
||||||
|
|
||||||
function drawTree() {
|
function drawTree() {
|
||||||
function htmlifyBranch(id, branch) {
|
function htmlifyBranch(id, branch) {
|
||||||
const maxTreeTitleLength = 35
|
const maxTreeTitleLength = 35
|
||||||
|
|
@ -297,8 +315,8 @@
|
||||||
http("GET", "/api/v0/tree", (body, status) => {
|
http("GET", "/api/v0/tree", (body, status) => {
|
||||||
if (status != 200)
|
if (status != 200)
|
||||||
throw `bad status getting tree: ${status}: ${body}`
|
throw `bad status getting tree: ${status}: ${body}`
|
||||||
const tree = JSON.parse(body)
|
lastTree = JSON.parse(body)
|
||||||
document.getElementById("tree").innerHTML = htmlifyBranch("", tree)
|
document.getElementById("tree").innerHTML = htmlifyBranch("", lastTree)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue