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.

96 lines
2.5 KiB
JavaScript

class View {
4 years ago
constructor() {}
4 years ago
drawDirTree(
dirtree,
ulToAdd = document.getElementsByTagName("ul")[0],
parrentObj
) {
var dirtreeul = document.getElementsByTagName("ul");
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[0]);
tag.appendChild(text);
tag.classList.add("caret");
ulToAdd.appendChild(tag);
if (dirtree.length > 1) {
var newul = document.createElement("ul");
newul.classList.add("nested");
tag.parentElement.appendChild(newul);
for (let i = 1; i < dirtree.length; i++) {
if (Array.isArray(dirtree[i])) {
4 years ago
this.drawDirTree(dirtree[i], newul, parrentObj);
4 years ago
} else {
var tag = document.createElement("li");
var text = document.createTextNode(dirtree[i]);
4 years ago
tag.appendChild(text);
newul.appendChild(tag);
4 years ago
var _this = this;
tag.addEventListener("click", function () {
parrentObj.loadFile(dirtree[0] + dirtree[i]);
});
}
}
}
}
4 years ago
4 years ago
openFile(fileread) {
let textArea = document.getElementsByTagName("textarea")[0];
textArea.disabled = false;
4 years ago
textArea.value = fileread;
4 years ago
}
4 years ago
removeDirTree() {
let mainul = document.getElementsByTagName("ul")[0];
while (mainul.firstChild) {
mainul.lastChild.remove();
4 years ago
}
this.hloubka = 1;
4 years ago
}
dirTreeToggler() {
var toggler = document.getElementsByClassName("caret");
var i;
function addClass() {
this.nextSibling.classList.toggle("active");
this.classList.toggle("caret-down");
}
for (i = 0; i < toggler.length; i++) {
toggler[i].addEventListener("click", addClass);
}
toggler[0].classList.add("caret-down");
if (toggler[0].nextSibling) {
toggler[0].nextSibling.classList.add("active");
}
toggler[0].removeEventListener("click", addClass);
}
openSettings() {
var settings = document.getElementsByClassName("settingsbg")[0];
settings.style.display = "grid";
let repo = document.getElementById("inputRepository");
let baseDir = document.getElementById("inputBaseDir");
4 years ago
repo.value = localStorage.getItem("repo");
baseDir.value = localStorage.getItem("baseDir");
}
closeSettings() {
var settings = document.getElementsByClassName("settingsbg")[0];
settings.style.removeProperty("display");
}
showSaveButton(show) {
var saveButton = document.getElementById("saveBtn");
if(show) {
saveButton.disabled = false;
} else {
saveButton.disabled = true;
}
}
}