Files
CoMato/js/controller.js
2020-12-22 18:37:02 +01:00

44 lines
1.0 KiB
JavaScript

class Controller {
constructor(model, view) {
this.model = model;
this.view = view;
this.redrawDirTree(view);
var cloneBtn = document.getElementsByClassName("clone")[0];
var purgeBtn = document.getElementsByClassName("wipe")[0];
cloneBtn.addEventListener("click", this.cloneRep.bind(this));
purgeBtn.addEventListener("click", this.wipeFS.bind(this));
}
wipeFS() {
this.model.wipeFS();
//window.location.reload();
this.redrawDirTree(this.view);
}
cloneRep(repurl) {
var that = this;
var loading = document.getElementsByClassName("loading")[0];
loading.style.display = "grid";
this.model.cloneRep().then(
function (value) {
loading.style.removeProperty("display");
that.redrawDirTree(that.view);
},
function (error) {}
);
}
redrawDirTree(view) {
this.model.dirTree().then(
function (value) {
view.removeDirTree();
view.drawDirTree(value);
view.dirTreeToggler();
},
function (error) {}
);
}
}