HTML and CSS Reference
In-Depth Information
Listing 3.11. app.js—Reading the file list using the directory reader
Next, you'll discover how to implement the View, Edit, and Delete buttons displayed for
each of the files in the filesystem.
3.3.3. Loading, viewing, editing, and deleting files
Back in the displayFileSystem function in listing 3.9 , you may have noticed an if
block that called a function named loadFile if the current view was the editor view.
Let's go ahead and implement that function now, as well as some small functions that will
allow users to view, edit, and delete files in the filesystem.
Step 3: Load files in the File Editor view using the File API
The loadFile function uses the File System API method getFile to retrieve the
FileEntry from the filesystem. In order to read the file contents, loadFile uses the File
API method readAsText . Lastly, loadFile displays the file contents to the visual and
HTML editors. Add the code from the following listing to app.js right after the update-
BrowserFilesList function you added previously.
Search WWH ::




Custom Search