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]; var settingsBtn = document.getElementsByClassName("settingsBtn")[0]; var settingsClose = document.getElementsByClassName("close"); var settingsSubmit = document.getElementById("settingsSubmit"); cloneBtn.addEventListener("click", this.cloneRep.bind(this)); purgeBtn.addEventListener("click", this.wipeFS.bind(this)); settingsBtn.addEventListener("click", view.openSettings.bind(this)); for (let i = 0; i < settingsClose.length; i++) { settingsClose[i].addEventListener("click", view.closeSettings.bind(this)); } settingsSubmit.addEventListener("click", this.saveSettings.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) {} ); } saveSettings() { let repo = document.getElementById("inputRepository"); let baseDir = document.getElementById("inputBaseDir"); this.model.setRepo(repo.value); this.model.setBaseDir(baseDir.value); this.redrawDirTree(this.view); this.view.closeSettings(); console.log(repo.value); } }