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.

80 lines
2.2 KiB
JavaScript

class View {
constructor() {
document.body.style.backgroundColor = "olive";
}
hloubka = 1;
showfiles(dir) {
console.log(dir)
}
showDirTree(dirtree) {
var dirtreeul = document.getElementsByTagName("ul");
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[0]);
tag.appendChild(text);
tag.style.fontWeight = "bold";
dirtreeul[dirtreeul.length - this.hloubka].appendChild(tag);
if (dirtree.length > 1) {
var newul = document.createElement("ul");
tag.parentElement.append(newul);
for (let i = 1; i < dirtree.length; i++) {
if (Array.isArray(dirtree[i])) {
this.showDirTree(dirtree[i]);
}else{
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[i]);
tag.appendChild(text)
newul.appendChild(tag)
}
}
this.hloubka++;
}
/*if(dirtree.length > 1) {
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[0]);
tag.appendChild(text);
tag.style.fontWeight = "bold"
mainul.appendChild(tag);
var newul = document.createElement("ul");
tag.parentElement.append(newul);
for (let i = 1; i < dirtree.length; i++) {
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[i]);
tag.appendChild(text);
newul.appendChild(tag);
}
}else{
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[0]);
tag.appendChild(text);
mainul.appendChild(tag);
}*/
/*for (let i = 1; i < dirtree.length; i++) {
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[i][0]);
tag.appendChild(text);
mainul.appendChild(tag);
if(dirtree[i].length > 1) {
//this.showDir(dirtree[i])
var newul = document.createElement("ul")
tag.parentElement.append(newul)
for (let i = 1; i < dirtree.length; i++) {
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[i]);
tag.appendChild(text);
newul.appendChild(tag);
}
}
}*/
}
}