Book Image

Node.js Blueprints

By : Krasimir Stefanov Tsonev
Book Image

Node.js Blueprints

By: Krasimir Stefanov Tsonev

Overview of this book

Table of Contents (19 chapters)
Node.js Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 to delegate this calling to another method. Along with updating the current location area, we will refresh the files area too. So, it makes sense to write a render function. At the moment, the method calls only updateCurrentLocation, but we will add...