July 2017
Intermediate to advanced
300 pages
5h 43m
English
What are our requirements for the DirList view? It renders the list of directories in the current path. When a user selects a directory from the list, it changes the current path. Subsequently, it updates the list to match the content of the new location:
./js/View/DirList.js
class DirListView { constructor( boundingEl, dirService ){ this.el = boundingEl; this.dir = dirService; // Subscribe on DirService updates dirService.on( "update", () => this.update( dirService.getDirList() ) ); } onOpenDir( e ){ e.preventDefault(); this.dir.setDir( e.target.dataset.file ); } update( collection ) { this.el.innerHTML = ""; collection.forEach(( fInfo ) => { this.el.insertAdjacentHTML( "beforeend", `<li class="dir-list__li" ...Read now
Unlock full access