You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/06/18 02:54:02 UTC
[5/5] git commit: added docs + tests
added docs + tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/acf384a6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/acf384a6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/acf384a6
Branch: refs/heads/master
Commit: acf384a665e8b0c00fced82c66b975dee9eb072e
Parents: 66ab05e
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 17:53:54 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 17:53:54 2013 -0700
----------------------------------------------------------------------
docs/directoryentry/directoryentry.md | 390 +++
docs/directoryreader/directoryreader.md | 69 +
docs/file.md | 91 +
docs/fileentry/fileentry.md | 323 ++
docs/fileerror/fileerror.md | 51 +
docs/fileobj/fileobj.md | 83 +
docs/filereader/filereader.md | 259 ++
docs/filesystem/filesystem.md | 95 +
docs/fileuploadoptions/fileuploadoptions.md | 47 +
docs/fileuploadresult/fileuploadresult.md | 42 +
docs/filewriter/filewriter.md | 233 ++
docs/flags/flags.md | 49 +
docs/localfilesystem/localfilesystem.md | 110 +
docs/metadata/metadata.md | 54 +
plugin.xml | 3 +-
test/autotest/html/HtmlReporter.js | 101 +
test/autotest/html/HtmlReporterHelpers.js | 60 +
test/autotest/html/ReporterView.js | 164 +
test/autotest/html/SpecView.js | 79 +
test/autotest/html/SuiteView.js | 22 +
test/autotest/html/TrivialReporter.js | 192 ++
test/autotest/index.html | 59 +
test/autotest/jasmine.css | 81 +
test/autotest/jasmine.js | 2530 +++++++++++++++
test/autotest/pages/.DS_Store | Bin 0 -> 6148 bytes
test/autotest/pages/file.html | 90 +
test/autotest/test-runner.js | 62 +
test/autotest/tests/.DS_Store | Bin 0 -> 6148 bytes
test/autotest/tests/file.tests.js | 3574 ++++++++++++++++++++++
test/cordova-incl.js | 85 +
test/index.html | 64 +
test/main.js | 162 +
test/master.css | 164 +
33 files changed, 9386 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/directoryentry/directoryentry.md
----------------------------------------------------------------------
diff --git a/docs/directoryentry/directoryentry.md b/docs/directoryentry/directoryentry.md
new file mode 100644
index 0000000..de01dd5
--- /dev/null
+++ b/docs/directoryentry/directoryentry.md
@@ -0,0 +1,390 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+DirectoryEntry
+==============
+
+This object represents a directory on a file system, as defined by the
+[W3C Directories and Systems](http://www.w3.org/TR/file-system-api/)
+specification.
+
+Properties
+----------
+
+- __isFile__: Always false. _(boolean)_
+- __isDirectory__: Always true. _(boolean)_
+- __name__: The name of the `DirectoryEntry`, excluding the path leading to it. _(DOMString)_
+- __fullPath__: The full absolute path from the root to the `DirectoryEntry`. _(DOMString)_
+
+__NOTE:__ The following attribute is defined by the W3C specification,
+but is _not_ supported:
+
+- __filesystem__: The file system on which the `DirectoryEntry` resides. _(FileSystem)_
+
+Methods
+-------
+
+The following methods can be invoked on a `DirectoryEntry` object:
+
+- __getMetadata__: Look up metadata about a directory.
+- __setMetadata__: Set metadata on a directory.
+- __moveTo__: Move a directory to a different location on the file system.
+- __copyTo__: Copy a directory to a different location on the file system.
+- __toURL__: Return a URL to help locate a directory.
+- __remove__: Delete a directory. The directory must be empty.
+- __getParent__: Look up the parent directory.
+- __createReader__: Create a new `DirectoryReader` that can read entries from a directory.
+- __getDirectory__: Create or look up a directory.
+- __getFile__: Create or look up a file.
+- __removeRecursively__: Delete a directory and all of its contents.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+getMetadata
+-----------
+
+Look up metadata about a directory.
+
+__Parameters:__
+
+- __successCallback__: A callback function to execute with a `Metadata` object. _(Function)_
+- __errorCallback__: A callback function to execute if an error occurs when retrieving the `Metadata`. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(metadata) {
+ console.log("Last Modified: " + metadata.modificationTime);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ // Request the metadata object for this entry
+ entry.getMetadata(success, fail);
+
+setMetadata
+----------------
+
+Set metadata on a directory.
+__Currently works only on iOS.__ - this will set the extended attributes of a directory.
+
+__Parameters:__
+
+- __successCallback__: A callback that executes when the metadata is successfully set. _(Function)_
+- __errorCallback__: A callback that executes when the metadata fails to be set. _(Function)_
+- __metadataObject__: An object that contains the metadata's keys and values. _(Object)_
+
+__Quick Example__
+
+ function success() {
+ console.log("The metadata was successfully set.");
+ }
+
+ function fail() {
+ alert("There was an error in setting the metadata");
+ }
+
+ // Set the metadata
+ entry.setMetadata(success, fail, { "com.apple.MobileBackup": 1});
+
+__iOS Quirk__
+
+- Only the `com.apple.MobileBackup` extended attribute is supported. Set the value to `1` to prevent the directory from being backed up to iCloud. Set the value to `0` to re-enable the directory to be backed up to iCloud.
+
+__Quick Example__
+
+ function setFolderMetadata(localFileSystem, subFolder, metadataKey, metadataValue)
+ {
+ var onSetMetadataWin = function() {
+ console.log("success setting metadata")
+ }
+ var onSetMetadataFail = function() {
+ console.log("error setting metadata")
+ }
+
+ var onGetDirectoryWin = function(parent) {
+ var data = {};
+ data[metadataKey] = metadataValue;
+ parent.setMetadata(onSetMetadataWin, onSetMetadataFail, data);
+ }
+ var onGetDirectoryFail = function() {
+ console.log("error getting dir")
+ }
+
+ var onFSWin = function(fileSystem) {
+ fileSystem.root.getDirectory(subFolder, {create: true, exclusive: false}, onGetDirectoryWin, onGetDirectoryFail);
+ }
+
+ var onFSFail = function(evt) {
+ console.log(evt.target.error.code);
+ }
+
+ window.requestFileSystem(localFileSystem, 0, onFSWin, onFSFail);
+ }
+
+ setFolderMetadata(LocalFileSystem.PERSISTENT, "Backups", "com.apple.MobileBackup", 1);
+
+moveTo
+------
+
+Move a directory to a different location on the file system. An error results if the app attempts to:
+
+- move a directory inside itself or to any child at any depth.
+- move a directory into its parent if a name different from its current directory is not provided.
+- move a directory to a path occupied by a file.
+- move a directory to a path occupied by a directory that is not empty.
+
+Moving a directory on top of an existing empty directory attempts to
+delete and replace that directory.
+
+__Parameters:__
+
+- __parent__: The parent directory to which to move the directory. _(DirectoryEntry)_
+- __newName__: The new name of the directory. Defaults to the current name if unspecified. _(DOMString)_
+- __successCallback__: A callback that executes with the `DirectoryEntry` object for the new directory. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to move the directory. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(entry) {
+ console.log("New Path: " + entry.fullPath);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ function moveDir(entry) {
+ var parent = document.getElementById('parent').value,
+ parentName = parent.substring(parent.lastIndexOf('/')+1),
+ newName = document.getElementById('newName').value,
+ parentEntry = new DirectoryEntry(parentName, parent);
+
+ // move the directory to a new directory and rename it
+ entry.moveTo(parentEntry, newName, success, fail);
+ }
+
+copyTo
+------
+
+Copy a directory to a different location on the file system. An error results if the app attempts to:
+
+- copy a directory inside itself at any depth.
+- copy a directory into its parent if a name different from its current directory is not provided.
+
+Directory copies are always recursive, and copy all contents of the directory.
+
+__Parameters:__
+
+- __parent__: The parent directory to which to copy the directory. _(DirectoryEntry)_
+- __newName__: The new name of the directory. Defaults to the current name if unspecified. _(DOMString)_
+- __successCallback__: A callback that executes with the `DirectoryEntry` object for the new directory. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to copy the underlying directory. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function win(entry) {
+ console.log("New Path: " + entry.fullPath);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ function copyDir(entry) {
+ var parent = document.getElementById('parent').value,
+ parentName = parent.substring(parent.lastIndexOf('/')+1),
+ newName = document.getElementById('newName').value,
+ parentEntry = new DirectoryEntry(parentName, parent);
+
+ // copy the directory to a new directory and rename it
+ entry.copyTo(parentEntry, newName, success, fail);
+ }
+
+toURL
+-----
+
+Returns a URL that can be used to locate the directory.
+
+__Quick Example__
+
+ // Get the URL for this directory
+ var dirURL = entry.toURL();
+ console.log(dirURL);
+
+remove
+------
+
+Deletes a directory. An error results if the app attempts to:
+
+- delete a directory that is not empty.
+- delete the root directory of a filesystem.
+
+__Parameters:__
+
+- __successCallback__: A callback that executes after the directory is deleted. Invoked with no parameters. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to delete the directory. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(entry) {
+ console.log("Removal succeeded");
+ }
+
+ function fail(error) {
+ alert('Error removing directory: ' + error.code);
+ }
+
+ // remove this directory
+ entry.remove(success, fail);
+
+getParent
+---------
+
+Look up the parent `DirectoryEntry` containing the directory.
+
+__Parameters:__
+
+- __successCallback__: A callback that is passed the directory's parent `DirectoryEntry`. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to retrieve the parent `DirectoryEntry`. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(parent) {
+ console.log("Parent Name: " + parent.name);
+ }
+
+ function fail(error) {
+ alert('Failed to get parent directory: ' + error.code);
+ }
+
+ // Get the parent DirectoryEntry
+ entry.getParent(success, fail);
+
+createReader
+------------
+
+Creates a new DirectoryReader to read entries in a directory.
+
+__Quick Example__
+
+ // create a directory reader
+ var directoryReader = entry.createReader();
+
+getDirectory
+------------
+
+Creates or looks up an existing directory. An error results if the app attempts to:
+
+- create a directory whose immediate parent does not yet exist.
+
+__Parameters:__
+
+- __path__: The path to the directory to be looked up or created. Either an absolute path, or a relative path from this `DirectoryEntry`. _(DOMString)_
+- __options__: Options to specify whether the directory is to be created if it doesn't exist. _(Flags)_
+- __successCallback__: A callback that executes with a `DirectoryEntry` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when creating or looking up the directory. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(parent) {
+ console.log("Parent Name: " + parent.name);
+ }
+
+ function fail(error) {
+ alert("Unable to create new directory: " + error.code);
+ }
+
+ // Retrieve an existing directory, or create it if it does not already exist
+ entry.getDirectory("newDir", {create: true, exclusive: false}, success, fail);
+
+getFile
+-------
+
+Creates or looks up a file. An error results if the app attempts to:
+
+- create a file whose immediate parent does not yet exist.
+
+__Parameters:__
+
+- __path__: The path to the file to be looked up or created. Either an absolute path, or a relative path from this `DirectoryEntry`. _(DOMString)_
+- __options__: Options to specify whether the file is created if it doesn't exist. _(Flags)_
+- __successCallback__: A callback that is passed a `FileEntry` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when creating or looking up the file. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(parent) {
+ console.log("Parent Name: " + parent.name);
+ }
+
+ function fail(error) {
+ alert("Failed to retrieve file: " + error.code);
+ }
+
+ // Retrieve an existing file, or create it if it does not exist
+ entry.getFile("newFile.txt", {create: true, exclusive: false}, success, fail);
+
+removeRecursively
+-----------------
+
+Deletes a directory and all of its contents. In the event of an error (such as trying to delete
+a directory containing a file that cannot be removed), some of the contents of the directory may
+be deleted. An error results if the app attempts to:
+
+- delete the root directory of a filesystem.
+
+__Parameters:__
+
+- __successCallback__: A callback that executes after the `DirectoryEntry` has been deleted. Invoked with no parameters. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to delete the `DirectoryEntry`. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(parent) {
+ console.log("Remove Recursively Succeeded");
+ }
+
+ function fail(error) {
+ alert("Failed to remove directory or it's contents: " + error.code);
+ }
+
+ // remove the directory and all it's contents
+ entry.removeRecursively(success, fail);
+
+BlackBerry Quirks
+-----------------
+
+May fail with a `ControlledAccessException` in the following cases:
+
+- An app attempts to access a directory created by a previous installation of the app.
+
+> Solution: ensure temporary directories are cleaned manually, or by the application prior to reinstallation.
+
+- If the device is connected by USB.
+
+> Solution: disconnect the USB cable from the device and run again.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/directoryreader/directoryreader.md
----------------------------------------------------------------------
diff --git a/docs/directoryreader/directoryreader.md b/docs/directoryreader/directoryreader.md
new file mode 100644
index 0000000..b37edb9
--- /dev/null
+++ b/docs/directoryreader/directoryreader.md
@@ -0,0 +1,69 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+DirectoryReader
+===============
+
+An object that lists files and directories within a directory, as
+defined in the
+[W3C Directories and Systems](http://www.w3.org/TR/file-system-api/)
+specification.
+
+Methods
+-------
+
+- __readEntries__: Read the entries in a directory.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+readEntries
+-----------
+
+Read the entries in this directory.
+
+__Parameters:__
+
+- __successCallback__: A callback that is passed an array of `FileEntry` and `DirectoryEntry` objects. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when retrieving the directory listing. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(entries) {
+ var i;
+ for (i=0; i<entries.length; i++) {
+ console.log(entries[i].name);
+ }
+ }
+
+ function fail(error) {
+ alert("Failed to list directory contents: " + error.code);
+ }
+
+ // Get a directory reader
+ var directoryReader = dirEntry.createReader();
+
+ // Get a list of all the entries in the directory
+ directoryReader.readEntries(success,fail);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/file.md
----------------------------------------------------------------------
diff --git a/docs/file.md b/docs/file.md
new file mode 100644
index 0000000..eed64c0
--- /dev/null
+++ b/docs/file.md
@@ -0,0 +1,91 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+File
+==========
+
+> An API to read, write and navigate file system hierarchies, based on the [W3C File API](http://www.w3.org/TR/FileAPI).
+
+Objects
+-------
+
+- DirectoryEntry
+- DirectoryReader
+- File
+- FileEntry
+- FileError
+- FileReader
+- FileSystem
+- FileTransfer
+- FileTransferError
+- FileUploadOptions
+- FileUploadResult
+- FileWriter
+- Flags
+- LocalFileSystem
+- Metadata
+
+Permissions
+-----------
+
+### Android
+
+#### app/res/xml/config.xml
+
+ <plugin name="File" value="org.apache.cordova.FileUtils" />
+ <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer" />
+
+#### app/AndroidManifest.xml
+
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+### Bada
+
+ No permissions are required.
+
+### BlackBerry WebWorks
+
+#### www/plugins.xml
+
+ <plugin name="File" value="org.apache.cordova.file.FileManager" />
+ <plugin name="FileTransfer" value="org.apache.cordova.http.FileTransfer" />
+
+#### www/config.xml
+
+ <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
+ <feature id="blackberry.utils" required="true" version="1.0.0.0" />
+ <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
+ <rim:permissions>
+ <rim:permit>access_shared</rim:permit>
+ </rim:permissions>
+
+### iOS
+
+#### config.xml
+
+ <plugin name="File" value="CDVFile" />
+ <plugin name="FileTransfer" value="CDVFileTransfer" />
+
+### webOS
+
+ No permissions are required.
+
+### Windows Phone
+
+ No permissions are required.
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/fileentry/fileentry.md
----------------------------------------------------------------------
diff --git a/docs/fileentry/fileentry.md b/docs/fileentry/fileentry.md
new file mode 100644
index 0000000..f362833
--- /dev/null
+++ b/docs/fileentry/fileentry.md
@@ -0,0 +1,323 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileEntry
+==========
+
+Represents a file on a file system, as defined in the
+[W3C Directories and Systems](http://www.w3.org/TR/file-system-api/)
+specification.
+
+Properties
+----------
+
+- __isFile__: Always true. _(boolean)_
+- __isDirectory__: Always false. _(boolean)_
+- __name__: The name of the `FileEntry`, excluding the path leading to it. _(DOMString)_
+- __fullPath__: The full absolute path from the root to the `FileEntry`. _(DOMString)_
+
+__NOTE:__ The following attribute is defined by the W3C specification,
+but is _not_ supported:
+
+- __filesystem__: The file system on which the `FileEntry` resides. _(FileSystem)_
+
+Methods
+-------
+
+- __getMetadata__: Look up metadata about a file.
+- __setMetadata__: Set metadata on a file.
+- __moveTo__: Move a file to a different location on the file system.
+- __copyTo__: Copy a file to a different location on the file system.
+- __toURL__: Return a URL that can be used to locate a file.
+- __remove__: Delete a file.
+- __getParent__: Look up the parent directory.
+- __createWriter__: Creates a `FileWriter` object that can be used to write to a file.
+- __file__: Creates a `File` object containing file properties.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+getMetadata
+----------------
+
+Look up metadata about a file.
+
+__Parameters:__
+
+- __successCallback__: A callback that is passed a `Metadata` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when retrieving the `Metadata`. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(metadata) {
+ console.log("Last Modified: " + metadata.modificationTime);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ // Request the metadata object for this entry
+ entry.getMetadata(success, fail);
+
+setMetadata
+----------------
+
+Set metadata on a file.
+
+__Currently works only on iOS.__
+- this will set the extended attributes of a file.
+
+__Parameters:__
+
+- __successCallback__: A callback that executes when the metadata is set. _(Function)_
+- __errorCallback__: A callback that executes when the metadata is not successfully set. _(Function)_
+- __metadataObject__: An object that contains the metadata's keys and values. _(Object)_
+
+__Quick Example__
+
+ function success() {
+ console.log("The metadata was successfully set.");
+ }
+
+ function fail() {
+ alert("There was an error in setting the metadata");
+ }
+
+ // Set the metadata
+ entry.setMetadata(success, fail, { "com.apple.MobileBackup": 1});
+
+__iOS Quirk__
+
+- Only the `com.apple.MobileBackup` extended attribute is supported. Set the value to `1` to prevent the file from being backed up to iCloud. Set the value to `0` to re-enable the file to be backed up to iCloud.
+
+__Quick Example__
+
+ function setFileMetadata(localFileSystem, filePath, metadataKey, metadataValue)
+ {
+ var onSetMetadataWin = function() {
+ console.log("success setting metadata")
+ }
+ var onSetMetadataFail = function() {
+ console.log("error setting metadata")
+ }
+
+ var onGetFileWin = function(parent) {
+ var data = {};
+ data[metadataKey] = metadataValue;
+ parent.setMetadata(onSetMetadataWin, onSetMetadataFail, data);
+ }
+ var onGetFileFail = function() {
+ console.log("error getting file")
+ }
+
+ var onFSWin = function(fileSystem) {
+ fileSystem.root.getFile(filePath, {create: true, exclusive: false}, onGetFileWin, onGetFileFail);
+ }
+
+ var onFSFail = function(evt) {
+ console.log(evt.target.error.code);
+ }
+
+ window.requestFileSystem(localFileSystem, 0, onFSWin, onFSFail);
+ }
+
+ setFileMetadata(LocalFileSystem.PERSISTENT, "Backups/sqlite.db", "com.apple.MobileBackup", 1);
+
+moveTo
+------
+
+Move a file to a different location on the file system. An error
+results if the app attempts to:
+
+- move a file into its parent if a name different from its current one isn't provided;
+- move a file to a path occupied by a directory;
+
+In addition, moving a file on top of an existing file attempts to
+delete and replace that file.
+
+__Parameters:__
+
+- __parent__: The parent directory to which to move the file. _(DirectoryEntry)_
+- __newName__: The new name of the file. Defaults to the current name if unspecified. _(DOMString)_
+- __successCallback__: A callback that is passed the new files `FileEntry` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to move the file. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(entry) {
+ console.log("New Path: " + entry.fullPath);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ function moveFile(entry) {
+ var parent = document.getElementById('parent').value,
+ parentName = parent.substring(parent.lastIndexOf('/')+1),
+ parentEntry = new DirectoryEntry(parentName, parent);
+
+ // move the file to a new directory and rename it
+ entry.moveTo(parentEntry, "newFile.txt", success, fail);
+ }
+
+copyTo
+------
+
+Copy a file to a new location on the file system. An error results if
+the app attempts to:
+
+- copy a file into its parent if a name different from its current one is not provided.
+
+__Parameters:__
+
+- __parent__: The parent directory to which to copy the file. _(DirectoryEntry)_
+- __newName__: The new name of the file. Defaults to the current name if unspecified. _(DOMString)_
+- __successCallback__: A callback that is passed the new file's `FileEntry` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to copy the file. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function win(entry) {
+ console.log("New Path: " + entry.fullPath);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ function copyFile(entry) {
+ var parent = document.getElementById('parent').value,
+ parentName = parent.substring(parent.lastIndexOf('/')+1),
+ parentEntry = new DirectoryEntry(parentName, parent);
+
+ // copy the file to a new directory and rename it
+ entry.copyTo(parentEntry, "file.copy", success, fail);
+ }
+
+toURL
+-----
+
+Returns a URL that can be used to locate the file.
+
+__Quick Example__
+
+ // Request the URL for this entry
+ var fileURL = entry.toURL();
+ console.log(fileURL);
+
+remove
+------
+
+Deletes a file.
+
+__Parameters:__
+
+- __successCallback__: A callback that executes after the file has been deleted. Invoked with no parameters. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to delete the file. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(entry) {
+ console.log("Removal succeeded");
+ }
+
+ function fail(error) {
+ alert('Error removing file: ' + error.code);
+ }
+
+ // remove the file
+ entry.remove(success, fail);
+
+getParent
+---------
+
+Look up the parent `DirectoryEntry` containing the file.
+
+__Parameters:__
+
+- __successCallback__: A callback that is passed the file's parent `DirectoryEntry`. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when attempting to retrieve the parent `DirectoryEntry`. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(parent) {
+ console.log("Parent Name: " + parent.name);
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ // Get the parent DirectoryEntry
+ entry.getParent(success, fail);
+
+createWriter
+------------
+
+Create a `FileWriter` object associated with the file represented by the `FileEntry`.
+
+__Parameters:__
+
+- __successCallback__: A callback that is passed a `FileWriter` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs while attempting to create the FileWriter. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(writer) {
+ writer.write("Some text to the file");
+ }
+
+ function fail(error) {
+ alert(error.code);
+ }
+
+ // create a FileWriter to write to the file
+ entry.createWriter(success, fail);
+
+file
+----
+
+Return a `File` object that represents the current state of the file
+that this `FileEntry` represents.
+
+__Parameters:__
+
+- __successCallback__: A callback that is passed a `File` object. _(Function)_
+- __errorCallback__: A callback that executes if an error occurs when creating the `File` object, such as when the file no longer exists. Invoked with a `FileError` object. _(Function)_
+
+__Quick Example__
+
+ function success(file) {
+ console.log("File size: " + file.size);
+ }
+
+ function fail(error) {
+ alert("Unable to retrieve file properties: " + error.code);
+ }
+
+ // obtain properties of a file
+ entry.file(success, fail);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/fileerror/fileerror.md
----------------------------------------------------------------------
diff --git a/docs/fileerror/fileerror.md b/docs/fileerror/fileerror.md
new file mode 100644
index 0000000..c34c6be
--- /dev/null
+++ b/docs/fileerror/fileerror.md
@@ -0,0 +1,51 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileError
+========
+
+A `FileError` object is set when an error occurs in any of the File API methods.
+
+Properties
+----------
+
+- __code__: One of the predefined error codes listed below.
+
+Constants
+---------
+
+- `FileError.NOT_FOUND_ERR`
+- `FileError.SECURITY_ERR`
+- `FileError.ABORT_ERR`
+- `FileError.NOT_READABLE_ERR`
+- `FileError.ENCODING_ERR`
+- `FileError.NO_MODIFICATION_ALLOWED_ERR`
+- `FileError.INVALID_STATE_ERR`
+- `FileError.SYNTAX_ERR`
+- `FileError.INVALID_MODIFICATION_ERR`
+- `FileError.QUOTA_EXCEEDED_ERR`
+- `FileError.TYPE_MISMATCH_ERR`
+- `FileError.PATH_EXISTS_ERR`
+
+Description
+-----------
+
+The `FileError` object is the only parameter provided to any of the
+File API's error callbacks. To determine the type of error, compare
+its `code` property to any of the listings above.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/fileobj/fileobj.md
----------------------------------------------------------------------
diff --git a/docs/fileobj/fileobj.md b/docs/fileobj/fileobj.md
new file mode 100644
index 0000000..ee5f1d4
--- /dev/null
+++ b/docs/fileobj/fileobj.md
@@ -0,0 +1,83 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+File
+====
+
+This object contains attributes of a single file.
+
+Properties
+----------
+
+- __name__: The name of the file. _(DOMString)_
+- __fullPath__: The full path of the file including the file name. _(DOMString)_
+- __type__: The mime type of the file. _(DOMString)_
+- __lastModifiedDate__: The last time the file was modified. _(Date)_
+- __size__: The size of the file in bytes. _(long)_
+
+Methods
+-------
+
+- __slice__: Select only a portion of the file to be read.
+
+Details
+-------
+
+The `File` object contains attributes of a single file. You can get
+an instance of a `File` object by calling a `FileEntry` object's
+`file()` method.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+slice
+--------------
+
+Return a new `File` object, for which `FileReader` returns only the
+specified portion of the file. Negative values for `start` or `end`
+are measured from the end of the file. Indexes are positioned
+relative to the current slice. (See the full example below.)
+
+__Parameters:__
+
+- __start__: The index of the first byte to read, inclusive.
+- __end__: The index of the byte after the last one to read.
+
+__Quick Example__
+
+ var slicedFile = file.slice(10, 30);
+
+__Full Example__
+
+ var slice1 = file.slice(100, 400);
+ var slice2 = slice1.slice(20, 35);
+
+ var slice3 = file.slice(120, 135);
+ // slice2 and slice3 are equivalent.
+
+__Supported Platforms:__
+
+- Android
+- iOS
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/filereader/filereader.md
----------------------------------------------------------------------
diff --git a/docs/filereader/filereader.md b/docs/filereader/filereader.md
new file mode 100644
index 0000000..25f6ff0
--- /dev/null
+++ b/docs/filereader/filereader.md
@@ -0,0 +1,259 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileReader
+==========
+
+The `FileReader` allows basic access to a file.
+
+Properties
+----------
+
+- __readyState__: One of the reader's three possible states, either `EMPTY`, `LOADING` or `DONE`.
+- __result__: The contents of the file that have been read. _(DOMString)_
+- __error__: An object containing errors. _(FileError)_
+- __onloadstart__: Called when the read starts. _(Function)_
+- __onload__: Called when the read has successfully completed. _(Function)_
+- __onabort__: Called when the read has been aborted. For instance, by invoking the `abort()` method. _(Function)_
+- __onerror__: Called when the read has failed. _(Function)_
+- __onloadend__: Called when the request has completed (either in success or failure). _(Function)_
+
+__NOTE:__ The following porperty is not supported:
+
+- __onprogress__: Called while reading the file, reporting progress in terms of `progress.loaded`/`progress.total`. _(Function)_
+
+Methods
+-------
+
+- __abort__: Aborts reading file.
+- __readAsDataURL__: Read file and return data as a base64-encoded data URL.
+- __readAsText__: Reads text file.
+- __readAsBinaryString__: Reads file as binary and returns a binary string.
+- __readAsArrayBuffer__: Reads file as an `ArrayBuffer`.
+
+Details
+-------
+
+The `FileReader` object offers a way to read files from the device's
+file system. Files can be read as text or as a base64 data-encoded
+string. Event listeners receive the `loadstart`, `progress`, `load`,
+`loadend`, `error`, and `abort` events.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+Read As Data URL
+----------------
+
+__Parameters:__
+
+- __file__: the file object to read.
+
+Quick Example
+-------------
+
+ function win(file) {
+ var reader = new FileReader();
+ reader.onloadend = function (evt) {
+ console.log("read success");
+ console.log(evt.target.result);
+ };
+ reader.readAsDataURL(file);
+ };
+
+ var fail = function (evt) {
+ console.log(error.code);
+ };
+
+ entry.file(win, fail);
+
+Read As Text
+------------
+
+__Parameters:__
+
+- __file__: the file object to read.
+- __encoding__: the encoding to use to encode the file's content. Default is UTF8.
+
+Quick Example
+-------------
+
+ function win(file) {
+ var reader = new FileReader();
+ reader.onloadend = function (evt) {
+ console.log("read success");
+ console.log(evt.target.result);
+ };
+ reader.readAsText(file);
+ };
+
+ var fail = function (evt) {
+ console.log(error.code);
+ };
+
+ entry.file(win, fail);
+
+Abort Quick Example
+-------------------
+
+ function win(file) {
+ var reader = new FileReader();
+ reader.onloadend = function(evt) {
+ console.log("read success");
+ console.log(evt.target.result);
+ };
+ reader.readAsText(file);
+ reader.abort();
+ };
+
+ function fail(error) {
+ console.log(error.code);
+ }
+
+ entry.file(win, fail);
+
+Full Example
+------------
+
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>FileReader Example</title>
+
+ <script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
+ <script type="text/javascript" charset="utf-8">
+
+ // Wait for device API libraries to load
+ //
+ function onLoad() {
+ document.addEventListener("deviceready", onDeviceReady, false);
+ }
+
+ // device APIs are available
+ //
+ function onDeviceReady() {
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+ }
+
+ function gotFS(fileSystem) {
+ fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
+ }
+
+ function gotFileEntry(fileEntry) {
+ fileEntry.file(gotFile, fail);
+ }
+
+ function gotFile(file){
+ readDataUrl(file);
+ readAsText(file);
+ }
+
+ function readDataUrl(file) {
+ var reader = new FileReader();
+ reader.onloadend = function(evt) {
+ console.log("Read as data URL");
+ console.log(evt.target.result);
+ };
+ reader.readAsDataURL(file);
+ }
+
+ function readAsText(file) {
+ var reader = new FileReader();
+ reader.onloadend = function(evt) {
+ console.log("Read as text");
+ console.log(evt.target.result);
+ };
+ reader.readAsText(file);
+ }
+
+ function fail(evt) {
+ console.log(evt.target.error.code);
+ }
+
+ </script>
+ </head>
+ <body>
+ <h1>Example</h1>
+ <p>Read File</p>
+ </body>
+ </html>
+
+iOS Quirks
+----------
+- The __encoding__ parameter is not supported, and UTF8 encoding is always in effect.
+
+Read As Binary String
+---------------------
+
+Currently supported on iOS and Android only.
+
+__Parameters:__
+
+- __file__: the file object to read.
+
+Quick Example
+-------------
+
+ function win(file) {
+ var reader = new FileReader();
+ reader.onloadend = function (evt) {
+ console.log("read success");
+ console.log(evt.target.result);
+ };
+ reader.readAsBinaryString(file);
+ };
+
+ var fail = function (evt) {
+ console.log(error.code);
+ };
+
+ entry.file(win, fail);
+
+Read As Array Buffer
+--------------------
+
+Currently supported on iOS and Android only.
+
+__Parameters:__
+
+- __file__: the file object to read.
+
+Quick Example
+-------------
+
+ function win(file) {
+ var reader = new FileReader();
+ reader.onloadend = function (evt) {
+ console.log("read success");
+ console.log(new Uint8Array(evt.target.result));
+ };
+ reader.readAsArrayBuffer(file);
+ };
+
+ var fail = function (evt) {
+ console.log(error.code);
+ };
+
+ entry.file(win, fail);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/filesystem/filesystem.md
----------------------------------------------------------------------
diff --git a/docs/filesystem/filesystem.md b/docs/filesystem/filesystem.md
new file mode 100644
index 0000000..c8eaa2c
--- /dev/null
+++ b/docs/filesystem/filesystem.md
@@ -0,0 +1,95 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileSystem
+==========
+
+This object represents a file system.
+
+Properties
+----------
+
+- __name__: The name of the file system. _(DOMString)_
+- __root__: The root directory of the file system. _(DirectoryEntry)_
+
+Details
+-------
+
+The `FileSystem` object represents information about the file system.
+The name of the file system is unique across the list of exposed
+file systems. The root property contains a `DirectoryEntry` object
+that represents the file system's root directory.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+File System Quick Example
+-------------------------
+
+ function onSuccess(fileSystem) {
+ console.log(fileSystem.name);
+ console.log(fileSystem.root.name);
+ }
+
+ // request the persistent file system
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null);
+
+Full Example
+------------
+
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>File System Example</title>
+
+ <script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
+ <script type="text/javascript" charset="utf-8">
+
+ // Wait for device API libraries to load
+ //
+ document.addEventListener("deviceready", onDeviceReady, false);
+
+ // device APIs are available
+ //
+ function onDeviceReady() {
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
+ }
+
+ function onFileSystemSuccess(fileSystem) {
+ console.log(fileSystem.name);
+ console.log(fileSystem.root.name);
+ }
+
+ function fail(evt) {
+ console.log(evt.target.error.code);
+ }
+
+ </script>
+ </head>
+ <body>
+ <h1>Example</h1>
+ <p>File System</p>
+ </body>
+ </html>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/fileuploadoptions/fileuploadoptions.md
----------------------------------------------------------------------
diff --git a/docs/fileuploadoptions/fileuploadoptions.md b/docs/fileuploadoptions/fileuploadoptions.md
new file mode 100644
index 0000000..e0e6fe2
--- /dev/null
+++ b/docs/fileuploadoptions/fileuploadoptions.md
@@ -0,0 +1,47 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileUploadOptions
+========
+
+A `FileUploadOptions` object can be passed to the `FileTransfer`
+object's `upload()` method to specify additional parameters to the
+upload script.
+
+Properties
+----------
+
+- __fileKey__: The name of the form element. Defaults to `file`. (DOMString)
+- __fileName__: The file name to use when saving the file on the server. Defaults to `image.jpg`. (DOMString)
+- __mimeType__: The mime type of the data to upload. Defaults to `image/jpeg`. (DOMString)
+- __params__: A set of optional key/value pairs to pass in the HTTP request. (Object)
+- __chunkedMode__: Whether to upload the data in chunked streaming mode. Defaults to `true`. (Boolean)
+- __headers__: A map of header name/header values. Use an array to specify more than one value. (Object)
+
+Description
+-----------
+
+A `FileUploadOptions` object can be passed to the `FileTransfer`
+object's `upload()` method to specify additional parameters to the
+upload script.
+
+WP7 Quirk
+---------
+
+- __chunkedMode:__: Ignored on WP7.
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/fileuploadresult/fileuploadresult.md
----------------------------------------------------------------------
diff --git a/docs/fileuploadresult/fileuploadresult.md b/docs/fileuploadresult/fileuploadresult.md
new file mode 100644
index 0000000..4d9305a
--- /dev/null
+++ b/docs/fileuploadresult/fileuploadresult.md
@@ -0,0 +1,42 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileUploadResult
+========
+
+A `FileUploadResult` object is passed to the success callback of the
+`FileTransfer` object's `upload()` method.
+
+Properties
+----------
+
+- __bytesSent__: The number of bytes sent to the server as part of the upload. (long)
+- __responseCode__: The HTTP response code returned by the server. (long)
+- __response__: The HTTP response returned by the server. (DOMString)
+
+Description
+-----------
+
+The `FileUploadResult` object is returned via the success callback of
+the `FileTransfer` object's `upload()` method.
+
+iOS Quirks
+----------
+
+- Does not support `responseCode` or `bytesSent`.
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/filewriter/filewriter.md
----------------------------------------------------------------------
diff --git a/docs/filewriter/filewriter.md b/docs/filewriter/filewriter.md
new file mode 100644
index 0000000..2269c06
--- /dev/null
+++ b/docs/filewriter/filewriter.md
@@ -0,0 +1,233 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+FileWriter
+==========
+
+As object that allows you to create and write data to a file.
+
+Properties
+----------
+
+- __readyState__: One of the three possible states, either `INIT`, `WRITING`, or `DONE`.
+- __fileName__: The name of the file to be written. _(DOMString)_
+- __length__: The length of the file to be written. _(long)_
+- __position__: The current position of the file pointer. _(long)_
+- __error__: An object containing errors. _(FileError)_
+- __onwritestart__: Called when the write starts. _(Function)_
+- __onwrite__: Called when the request has completed successfully. _(Function)_
+- __onabort__: Called when the write has been aborted. For instance, by invoking the abort() method. _(Function)_
+- __onerror__: Called when the write has failed. _(Function)_
+- __onwriteend__: Called when the request has completed (either in success or failure). _(Function)_
+
+The following property is _not_ supported:
+
+- __onprogress__: Called while writing the file, reporting progress in terms of `progress.loaded`/`progress.total`. _(Function)_
+Methods
+-------
+
+- __abort__: Aborts writing the file.
+- __seek__: Moves the file pointer to the specified byte.
+- __truncate__: Shortens the file to the specified length.
+- __write__: Writes data to the file.
+
+Details
+-------
+
+The `FileWriter` object offers a way to write UTF-8 encoded files to
+the device file system. Applications respond to `writestart`,
+`progress`, `write`, `writeend`, `error`, and `abort` events.
+
+Each `FileWriter` corresponds to a single file, to which data can be
+written many times. The `FileWriter` maintains the file's `position`
+and `length` attributes, which allow the app to `seek` and `write`
+anywhere in the file. By default, the `FileWriter` writes to the
+beginning of the file, overwriting existing data. Set the optional
+`append` boolean to `true` in the `FileWriter`'s constructor to
+write to the end of the file.
+
+Text data is supported by all platforms listed below. Text is encoded as UTF-8 before being written to the filesystem. Some platforms also support binary data, which can be passed in as either an ArrayBuffer or a Blob.
+
+Supported Platforms
+-------------------
+
+### Text and Binary suport
+
+- Android
+- iOS
+
+### Text only support
+
+- BlackBerry WebWorks (OS 5.0 and higher)
+- Windows Phone 7 and 8
+- Windows 8
+
+Seek Quick Example
+------------------------------
+
+ function win(writer) {
+ // fast forwards file pointer to end of file
+ writer.seek(writer.length);
+ };
+
+ var fail = function(evt) {
+ console.log(error.code);
+ };
+
+ entry.createWriter(win, fail);
+
+Truncate Quick Example
+--------------------------
+
+ function win(writer) {
+ writer.truncate(10);
+ };
+
+ var fail = function(evt) {
+ console.log(error.code);
+ };
+
+ entry.createWriter(win, fail);
+
+Write Quick Example
+-------------------
+
+ function win(writer) {
+ writer.onwrite = function(evt) {
+ console.log("write success");
+ };
+ writer.write("some sample text");
+ };
+
+ var fail = function(evt) {
+ console.log(error.code);
+ };
+
+ entry.createWriter(win, fail);
+
+Binary Write Quick Example
+--------------------------
+
+ function win(writer) {
+ var data = new ArrayBuffer(5),
+ dataView = new Int8Array(data);
+ for (i=0; i < 5; i++) {
+ dataView[i] = i;
+ }
+ writer.onwrite = function(evt) {
+ console.log("write success");
+ };
+ writer.write(data);
+ };
+
+ var fail = function(evt) {
+ console.log(error.code);
+ };
+
+ entry.createWriter(win, fail);
+
+Append Quick Example
+--------------------
+
+ function win(writer) {
+ writer.onwrite = function(evt) {
+ console.log("write success");
+ };
+ writer.seek(writer.length);
+ writer.write("appended text");
+ };
+
+ var fail = function(evt) {
+ console.log(error.code);
+ };
+
+ entry.createWriter(win, fail);
+
+Abort Quick Example
+-------------------
+
+ function win(writer) {
+ writer.onwrite = function(evt) {
+ console.log("write success");
+ };
+ writer.write("some sample text");
+ writer.abort();
+ };
+
+ var fail = function(evt) {
+ console.log(error.code);
+ };
+
+ entry.createWriter(win, fail);
+
+Full Example
+------------
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>FileWriter Example</title>
+
+ <script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
+ <script type="text/javascript" charset="utf-8">
+
+ // Wait for device API libraries to load
+ //
+ document.addEventListener("deviceready", onDeviceReady, false);
+
+ // device APIs are available
+ //
+ function onDeviceReady() {
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+ }
+
+ function gotFS(fileSystem) {
+ fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry, fail);
+ }
+
+ function gotFileEntry(fileEntry) {
+ fileEntry.createWriter(gotFileWriter, fail);
+ }
+
+ function gotFileWriter(writer) {
+ writer.onwriteend = function(evt) {
+ console.log("contents of file now 'some sample text'");
+ writer.truncate(11);
+ writer.onwriteend = function(evt) {
+ console.log("contents of file now 'some sample'");
+ writer.seek(4);
+ writer.write(" different text");
+ writer.onwriteend = function(evt){
+ console.log("contents of file now 'some different text'");
+ }
+ };
+ };
+ writer.write("some sample text");
+ }
+
+ function fail(error) {
+ console.log(error.code);
+ }
+
+ </script>
+ </head>
+ <body>
+ <h1>Example</h1>
+ <p>Write File</p>
+ </body>
+ </html>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/flags/flags.md
----------------------------------------------------------------------
diff --git a/docs/flags/flags.md b/docs/flags/flags.md
new file mode 100644
index 0000000..504f323
--- /dev/null
+++ b/docs/flags/flags.md
@@ -0,0 +1,49 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+Flags
+=====
+
+Supplies arguments to the `DirectoryEntry` object's `getFile()` and
+`getDirectory()` methods, which look up or create files and
+directories, respectively.
+
+Properties
+----------
+
+- __create__: Indicates that the file or directory should be created if it does not already exist. _(boolean)_
+- __exclusive__: Has has no effect by itself, but when used with `create` causes the file or directory creation to fail if the target path already exists. _(boolean)_
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+Quick Example
+-------------
+
+ // Get the data directory, creating it if it doesn't exist.
+ dataDir = fileSystem.root.getDirectory("data", {create: true});
+
+ // Create the lock file, if and only if it doesn't exist.
+ lockFile = dataDir.getFile("lockfile.txt", {create: true, exclusive: true});
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/localfilesystem/localfilesystem.md
----------------------------------------------------------------------
diff --git a/docs/localfilesystem/localfilesystem.md b/docs/localfilesystem/localfilesystem.md
new file mode 100644
index 0000000..2b933c9
--- /dev/null
+++ b/docs/localfilesystem/localfilesystem.md
@@ -0,0 +1,110 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+LocalFileSystem
+===============
+
+This object provides a way to obtain root file systems.
+
+Methods
+----------
+
+- __requestFileSystem__: Requests a filesystem. _(Function)_
+- __resolveLocalFileSystemURI__: Retrieve a `DirectoryEntry` or `FileEntry` using local URI. _(Function)_
+
+Constants
+---------
+
+- `LocalFileSystem.PERSISTENT`: Used for storage that should not be removed by the user agent without application or user permission.
+- `LocalFileSystem.TEMPORARY`: Used for storage with no guarantee of persistence.
+
+Details
+-------
+
+The `LocalFileSystem` object methods are defined on the `window` object.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+Request File System Quick Example
+---------------------------------
+
+ function onSuccess(fileSystem) {
+ console.log(fileSystem.name);
+ }
+
+ // request the persistent file system
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError);
+
+Resolve Local File System URI Quick Example
+-------------------------------------------
+
+ function onSuccess(fileEntry) {
+ console.log(fileEntry.name);
+ }
+
+ window.resolveLocalFileSystemURI("file:///example.txt", onSuccess, onError);
+
+Full Example
+------------
+
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Local File System Example</title>
+
+ <script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
+ <script type="text/javascript" charset="utf-8">
+
+ // Wait for device API libraries to load
+ //
+ document.addEventListener("deviceready", onDeviceReady, false);
+
+ // device APIs are available
+ //
+ function onDeviceReady() {
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
+ window.resolveLocalFileSystemURI("file:///example.txt", onResolveSuccess, fail);
+ }
+
+ function onFileSystemSuccess(fileSystem) {
+ console.log(fileSystem.name);
+ }
+
+ function onResolveSuccess(fileEntry) {
+ console.log(fileEntry.name);
+ }
+
+ function fail(evt) {
+ console.log(evt.target.error.code);
+ }
+
+ </script>
+ </head>
+ <body>
+ <h1>Example</h1>
+ <p>Local File System</p>
+ </body>
+ </html>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/docs/metadata/metadata.md
----------------------------------------------------------------------
diff --git a/docs/metadata/metadata.md b/docs/metadata/metadata.md
new file mode 100644
index 0000000..bfa3a46
--- /dev/null
+++ b/docs/metadata/metadata.md
@@ -0,0 +1,54 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+Metadata
+==========
+
+An interface that supplies information about the state of a file or directory.
+
+Properties
+----------
+
+- __modificationTime__: The time when the file or directory was last modified. _(Date)_
+
+Details
+-------
+
+The `Metadata` object represents information about the state of a file
+or directory. Calling a `DirectoryEntry` or `FileEntry` object's
+`getMetadata()` method results in a `Metadata` instance.
+
+Supported Platforms
+-------------------
+
+- Android
+- BlackBerry WebWorks (OS 5.0 and higher)
+- iOS
+- Windows Phone 7 and 8
+- Windows 8
+
+Quick Example
+-------------
+
+ function win(metadata) {
+ console.log("Last Modified: " + metadata.modificationTime);
+ }
+
+ // Request the metadata object for this entry
+ entry.getMetadata(win, null);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 069c7ba..b107478 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -2,8 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
-id="org.apache.cordova.core.FileUtils"
- version="0.1.0">
+id="org.apache.cordova.core.FileUtils" version="0.1.0">
<name>File</name>
<js-module src="www/DirectoryEntry.js" name="DirectoryEntry">
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/test/autotest/html/HtmlReporter.js
----------------------------------------------------------------------
diff --git a/test/autotest/html/HtmlReporter.js b/test/autotest/html/HtmlReporter.js
new file mode 100644
index 0000000..7d9d924
--- /dev/null
+++ b/test/autotest/html/HtmlReporter.js
@@ -0,0 +1,101 @@
+jasmine.HtmlReporter = function(_doc) {
+ var self = this;
+ var doc = _doc || window.document;
+
+ var reporterView;
+
+ var dom = {};
+
+ // Jasmine Reporter Public Interface
+ self.logRunningSpecs = false;
+
+ self.reportRunnerStarting = function(runner) {
+ var specs = runner.specs() || [];
+
+ if (specs.length == 0) {
+ return;
+ }
+
+ createReporterDom(runner.env.versionString());
+ doc.body.appendChild(dom.reporter);
+
+ reporterView = new jasmine.HtmlReporter.ReporterView(dom);
+ reporterView.addSpecs(specs, self.specFilter);
+ };
+
+ self.reportRunnerResults = function(runner) {
+ reporterView && reporterView.complete();
+ };
+
+ self.reportSuiteResults = function(suite) {
+ reporterView.suiteComplete(suite);
+ };
+
+ self.reportSpecStarting = function(spec) {
+ if (self.logRunningSpecs) {
+ self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
+ }
+ };
+
+ self.reportSpecResults = function(spec) {
+ reporterView.specComplete(spec);
+ };
+
+ self.log = function() {
+ var console = jasmine.getGlobal().console;
+ if (console && console.log) {
+ if (console.log.apply) {
+ console.log.apply(console, arguments);
+ } else {
+ console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
+ }
+ }
+ };
+
+ self.specFilter = function(spec) {
+ if (!focusedSpecName()) {
+ return true;
+ }
+
+ return spec.getFullName().indexOf(focusedSpecName()) === 0;
+ };
+
+ return self;
+
+ function focusedSpecName() {
+ var specName;
+
+ (function memoizeFocusedSpec() {
+ if (specName) {
+ return;
+ }
+
+ var paramMap = [];
+ var params = doc.location.search.substring(1).split('&');
+
+ for (var i = 0; i < params.length; i++) {
+ var p = params[i].split('=');
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
+ }
+
+ specName = paramMap.spec;
+ })();
+
+ return specName;
+ }
+
+ function createReporterDom(version) {
+ dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
+ dom.banner = self.createDom('div', { className: 'banner' },
+ self.createDom('span', { className: 'title' }, "Jasmine "),
+ self.createDom('span', { className: 'version' }, version)),
+
+ dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
+ dom.alert = self.createDom('div', {className: 'alert'}),
+ dom.results = self.createDom('div', {className: 'results'},
+ dom.summary = self.createDom('div', { className: 'summary' }),
+ dom.details = self.createDom('div', { id: 'details' }))
+ );
+ }
+};
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/test/autotest/html/HtmlReporterHelpers.js
----------------------------------------------------------------------
diff --git a/test/autotest/html/HtmlReporterHelpers.js b/test/autotest/html/HtmlReporterHelpers.js
new file mode 100644
index 0000000..745e1e0
--- /dev/null
+++ b/test/autotest/html/HtmlReporterHelpers.js
@@ -0,0 +1,60 @@
+jasmine.HtmlReporterHelpers = {};
+
+jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
+ var el = document.createElement(type);
+
+ for (var i = 2; i < arguments.length; i++) {
+ var child = arguments[i];
+
+ if (typeof child === 'string') {
+ el.appendChild(document.createTextNode(child));
+ } else {
+ if (child) {
+ el.appendChild(child);
+ }
+ }
+ }
+
+ for (var attr in attrs) {
+ if (attr == "className") {
+ el[attr] = attrs[attr];
+ } else {
+ el.setAttribute(attr, attrs[attr]);
+ }
+ }
+
+ return el;
+};
+
+jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
+ var results = child.results();
+ var status = results.passed() ? 'passed' : 'failed';
+ if (results.skipped) {
+ status = 'skipped';
+ }
+
+ return status;
+};
+
+jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
+ var parentDiv = this.dom.summary;
+ var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
+ var parent = child[parentSuite];
+
+ if (parent) {
+ if (typeof this.views.suites[parent.id] == 'undefined') {
+ this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
+ }
+ parentDiv = this.views.suites[parent.id].element;
+ }
+
+ parentDiv.appendChild(childElement);
+};
+
+
+jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
+ for(var fn in jasmine.HtmlReporterHelpers) {
+ ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
+ }
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/test/autotest/html/ReporterView.js
----------------------------------------------------------------------
diff --git a/test/autotest/html/ReporterView.js b/test/autotest/html/ReporterView.js
new file mode 100644
index 0000000..6a6d005
--- /dev/null
+++ b/test/autotest/html/ReporterView.js
@@ -0,0 +1,164 @@
+jasmine.HtmlReporter.ReporterView = function(dom) {
+ this.startedAt = new Date();
+ this.runningSpecCount = 0;
+ this.completeSpecCount = 0;
+ this.passedCount = 0;
+ this.failedCount = 0;
+ this.skippedCount = 0;
+
+ this.createResultsMenu = function() {
+ this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
+ this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
+ ' | ',
+ this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
+
+ this.summaryMenuItem.onclick = function() {
+ dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
+ };
+
+ this.detailsMenuItem.onclick = function() {
+ showDetails();
+ };
+ };
+
+ this.addSpecs = function(specs, specFilter) {
+ this.totalSpecCount = specs.length;
+
+ this.views = {
+ specs: {},
+ suites: {}
+ };
+
+ for (var i = 0; i < specs.length; i++) {
+ var spec = specs[i];
+ this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
+ if (specFilter(spec)) {
+ this.runningSpecCount++;
+ }
+ }
+ };
+
+ this.specComplete = function(spec) {
+ this.completeSpecCount++;
+
+ if (isUndefined(this.views.specs[spec.id])) {
+ this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
+ }
+
+ var specView = this.views.specs[spec.id];
+
+ switch (specView.status()) {
+ case 'passed':
+ this.passedCount++;
+ break;
+
+ case 'failed':
+ this.failedCount++;
+ break;
+
+ case 'skipped':
+ this.skippedCount++;
+ break;
+ }
+
+ specView.refresh();
+ this.refresh();
+ };
+
+ this.suiteComplete = function(suite) {
+ var suiteView = this.views.suites[suite.id];
+ if (isUndefined(suiteView)) {
+ return;
+ }
+ suiteView.refresh();
+ };
+
+ this.refresh = function() {
+
+ if (isUndefined(this.resultsMenu)) {
+ this.createResultsMenu();
+ }
+
+ // currently running UI
+ if (isUndefined(this.runningAlert)) {
+ this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
+ dom.alert.appendChild(this.runningAlert);
+ }
+ this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
+
+ // skipped specs UI
+ if (isUndefined(this.skippedAlert)) {
+ this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
+ }
+
+ this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
+
+ if (this.skippedCount === 1 && isDefined(dom.alert)) {
+ dom.alert.appendChild(this.skippedAlert);
+ }
+
+ // passing specs UI
+ if (isUndefined(this.passedAlert)) {
+ this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
+ }
+ this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
+
+ // failing specs UI
+ if (isUndefined(this.failedAlert)) {
+ this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
+ }
+ this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
+
+ if (this.failedCount === 1 && isDefined(dom.alert)) {
+ dom.alert.appendChild(this.failedAlert);
+ dom.alert.appendChild(this.resultsMenu);
+ }
+
+ // summary info
+ this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
+ this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
+ };
+
+ this.complete = function() {
+ dom.alert.removeChild(this.runningAlert);
+
+ this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
+
+ if (this.failedCount === 0) {
+ dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
+ } else {
+ showDetails();
+ }
+
+ dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
+ };
+
+ return this;
+
+ function showDetails() {
+ if (dom.reporter.className.search(/showDetails/) === -1) {
+ dom.reporter.className += " showDetails";
+ }
+ }
+
+ function isUndefined(obj) {
+ return typeof obj === 'undefined';
+ }
+
+ function isDefined(obj) {
+ return !isUndefined(obj);
+ }
+
+ function specPluralizedFor(count) {
+ var str = count + " spec";
+ if (count > 1) {
+ str += "s"
+ }
+ return str;
+ }
+
+};
+
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
+
+
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/test/autotest/html/SpecView.js
----------------------------------------------------------------------
diff --git a/test/autotest/html/SpecView.js b/test/autotest/html/SpecView.js
new file mode 100644
index 0000000..e8a3c23
--- /dev/null
+++ b/test/autotest/html/SpecView.js
@@ -0,0 +1,79 @@
+jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
+ this.spec = spec;
+ this.dom = dom;
+ this.views = views;
+
+ this.symbol = this.createDom('li', { className: 'pending' });
+ this.dom.symbolSummary.appendChild(this.symbol);
+
+ this.summary = this.createDom('div', { className: 'specSummary' },
+ this.createDom('a', {
+ className: 'description',
+ href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
+ title: this.spec.getFullName()
+ }, this.spec.description)
+ );
+
+ this.detail = this.createDom('div', { className: 'specDetail' },
+ this.createDom('a', {
+ className: 'description',
+ href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
+ title: this.spec.getFullName()
+ }, this.spec.getFullName())
+ );
+};
+
+jasmine.HtmlReporter.SpecView.prototype.status = function() {
+ return this.getSpecStatus(this.spec);
+};
+
+jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
+ this.symbol.className = this.status();
+
+ switch (this.status()) {
+ case 'skipped':
+ break;
+
+ case 'passed':
+ this.appendSummaryToSuiteDiv();
+ break;
+
+ case 'failed':
+ this.appendSummaryToSuiteDiv();
+ this.appendFailureDetail();
+ break;
+ }
+};
+
+jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
+ this.summary.className += ' ' + this.status();
+ this.appendToSummary(this.spec, this.summary);
+};
+
+jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
+ this.detail.className += ' ' + this.status();
+
+ var resultItems = this.spec.results().getItems();
+ var messagesDiv = this.createDom('div', { className: 'messages' });
+
+ for (var i = 0; i < resultItems.length; i++) {
+ var result = resultItems[i];
+
+ if (result.type == 'log') {
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
+ } else if (result.type == 'expect' && result.passed && !result.passed()) {
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
+
+ if (result.trace.stack) {
+ messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
+ }
+ }
+ }
+
+ if (messagesDiv.childNodes.length > 0) {
+ this.detail.appendChild(messagesDiv);
+ this.dom.details.appendChild(this.detail);
+ }
+};
+
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/acf384a6/test/autotest/html/SuiteView.js
----------------------------------------------------------------------
diff --git a/test/autotest/html/SuiteView.js b/test/autotest/html/SuiteView.js
new file mode 100644
index 0000000..19a1efa
--- /dev/null
+++ b/test/autotest/html/SuiteView.js
@@ -0,0 +1,22 @@
+jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
+ this.suite = suite;
+ this.dom = dom;
+ this.views = views;
+
+ this.element = this.createDom('div', { className: 'suite' },
+ this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
+ );
+
+ this.appendToSummary(this.suite, this.element);
+};
+
+jasmine.HtmlReporter.SuiteView.prototype.status = function() {
+ return this.getSpecStatus(this.suite);
+};
+
+jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
+ this.element.className += " " + this.status();
+};
+
+jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
+