keep location
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-11-01 13:12:33 +01:00
parent b3cdcff067
commit a9f48a79a4
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -2,8 +2,9 @@
* Build the filetree * Build the filetree
* @param {HTMLElement} parent Root element of the filetree * @param {HTMLElement} parent Root element of the filetree
* @param {{name: string, is_dir: boolean, children: any[]}} data FileNode * @param {{name: string, is_dir: boolean, children: any[]}} data FileNode
* @param {string} location Current location, used for links creation
*/ */
const buildFileTree = (parent, data) => { const buildFileTree = (parent, data, location) => {
const ul = document.createElement("ul"); const ul = document.createElement("ul");
data.forEach((item) => { data.forEach((item) => {
const li = document.createElement("li"); const li = document.createElement("li");
@ -22,7 +23,11 @@ const buildFileTree = (parent, data) => {
ul.appendChild(li); ul.appendChild(li);
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
buildFileTree(li, item.children); buildFileTree(
li,
item.children,
item.is_dir ? location + `${item.name}/` : location
);
} }
}); });
@ -35,7 +40,8 @@ window.addEventListener("load", () => {
buildFileTree( buildFileTree(
fileTreeElement, fileTreeElement,
JSON.parse(dataElement.getAttribute("data-json")).children JSON.parse(dataElement.getAttribute("data-json")).children,
""
); );
dataElement.remove(); dataElement.remove();