You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

37 lines
1011 B
JavaScript

class View {
constructor() {}
drawDirTree(dirtree, ulToAdd = document.getElementsByTagName("ul")[0]) {
var dirtreeul = document.getElementsByTagName("ul");
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[0]);
tag.appendChild(text);
tag.style.fontWeight = "bold";
ulToAdd.appendChild(tag);
if (dirtree.length > 1) {
var newul = document.createElement("ul");
tag.parentElement.appendChild(newul);
for (let i = 1; i < dirtree.length; i++) {
if (Array.isArray(dirtree[i])) {
this.drawDirTree(dirtree[i], newul);
} else {
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[i]);
tag.appendChild(text);
newul.appendChild(tag);
}
}
}
}
removeDirTree() {
let mainul = document.getElementsByTagName("ul")[0];
while (mainul.firstChild) {
mainul.lastChild.remove();
}
this.hloubka = 1;
}
}