Implementing logic in HTML5 FileSystem API