O'Reilly logo

Node.js Blueprints by Krasimir Tsonev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Displaying and using the working directory

In this section, we will cover the main features of our file browser. At the end, our application will read the current working directory. It will show its content and the user will be able to navigate between the shown folders.

Displaying the current working directory

We put the value of api.cwd in the div with the currentLocation class. It is represented by the currentLocationArea private variable. We only need a function that sets the innerHTML property of the element:

var updateCurrentLocation = function() {
  currentLocationArea.innerHTML = api.cwd;
}

This is probably the simplest function of our class. We will call it every time we change the directory, which can happen pretty often. It's a good idea ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required