You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by de...@apache.org on 2012/02/08 21:14:02 UTC
[19/19] CB-226 Rename to Cordova.
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/file.js
----------------------------------------------------------------------
diff --git a/javascript/file.js b/javascript/file.js
index c1a592d..976696a 100644
--- a/javascript/file.js
+++ b/javascript/file.js
@@ -44,7 +44,7 @@ FileError.PATH_EXISTS_ERR = 12;
/**
* navigator.fileMgr
- *
+ *
* Provides file utility methods.
*/
(function() {
@@ -54,7 +54,7 @@ FileError.PATH_EXISTS_ERR = 12;
if (typeof navigator.fileMgr !== "undefined") {
return;
}
-
+
/**
* @constructor
*/
@@ -64,7 +64,7 @@ FileError.PATH_EXISTS_ERR = 12;
/**
* Returns the available memory in bytes for the root file system of the
* specified file path.
- *
+ *
* @param filePath A file system path
*/
FileMgr.prototype.getFreeDiskSpace = function(filePath) {
@@ -73,8 +73,8 @@ FileError.PATH_EXISTS_ERR = 12;
/**
* Tests whether file exists. Will return false if the path specifies a directory.
- *
- * @param fullPath The full path of the file
+ *
+ * @param fullPath The full path of the file
*/
FileMgr.prototype.testFileExists = function(fullPath) {
return blackberry.io.file.exists(fullPath);
@@ -82,7 +82,7 @@ FileError.PATH_EXISTS_ERR = 12;
/**
* Tests whether directory exists. Will return false if the path specifies a file.
- *
+ *
* @param fullPath The full path of the directory
*/
FileMgr.prototype.testDirectoryExists = function(fullPath) {
@@ -90,32 +90,32 @@ FileError.PATH_EXISTS_ERR = 12;
};
/**
- * Reads a file from the device and encodes the contents using the specified
- * encoding.
- *
+ * Reads a file from the device and encodes the contents using the specified
+ * encoding.
+ *
* @param fileName The full path of the file to read
* @param encoding The encoding to use to encode the file's content
* @param successCallback Callback invoked with file contents
* @param errorCallback Callback invoked on error
*/
FileMgr.prototype.readAsText = function(fileName, encoding, successCallback, errorCallback) {
- PhoneGap.exec(successCallback, errorCallback, "File", "readAsText", [fileName, encoding]);
+ Cordova.exec(successCallback, errorCallback, "File", "readAsText", [fileName, encoding]);
};
/**
- * Reads a file from the device and encodes the contents using BASE64 encoding.
- *
+ * Reads a file from the device and encodes the contents using BASE64 encoding.
+ *
* @param fileName The full path of the file to read.
* @param successCallback Callback invoked with file contents
* @param errorCallback Callback invoked on error
*/
FileMgr.prototype.readAsDataURL = function(fileName, successCallback, errorCallback) {
- PhoneGap.exec(successCallback, errorCallback, "File", "readAsDataURL", [fileName]);
+ Cordova.exec(successCallback, errorCallback, "File", "readAsDataURL", [fileName]);
};
/**
* Writes data to the specified file.
- *
+ *
* @param fileName The full path of the file to write
* @param data The data to be written
* @param position The position in the file to begin writing
@@ -123,32 +123,32 @@ FileError.PATH_EXISTS_ERR = 12;
* @param errorCallback Callback invoked on error
*/
FileMgr.prototype.write = function(fileName, data, position, successCallback, errorCallback) {
- PhoneGap.exec(successCallback, errorCallback, "File", "write", [fileName, data, position]);
+ Cordova.exec(successCallback, errorCallback, "File", "write", [fileName, data, position]);
};
/**
- * Changes the length of the specified file. Data beyond new length is discarded.
- *
+ * Changes the length of the specified file. Data beyond new length is discarded.
+ *
* @param fileName The full path of the file to truncate
* @param size The size to which the length of the file is to be adjusted
* @param successCallback Callback invoked after successful write operation
* @param errorCallback Callback invoked on error
*/
FileMgr.prototype.truncate = function(fileName, size, successCallback, errorCallback) {
- PhoneGap.exec(successCallback, errorCallback, "File", "truncate", [fileName, size]);
+ Cordova.exec(successCallback, errorCallback, "File", "truncate", [fileName, size]);
};
/**
* Define navigator.fileMgr object.
*/
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
navigator.fileMgr = new FileMgr();
});
}());
/**
* FileReader
- *
+ *
* Reads files from the device file system.
*/
var FileReader = FileReader || (function() {
@@ -174,24 +174,24 @@ var FileReader = FileReader || (function() {
this.onloadend = null; // When the request has completed (either in success or failure).
this.onabort = null; // When the read has been aborted. For instance, by invoking the abort() method.
};
-
+
/**
* States
*/
FileReader.EMPTY = 0;
FileReader.LOADING = 1;
FileReader.DONE = 2;
-
+
/**
* Abort read file operation.
*/
FileReader.prototype.abort = function() {
var event;
-
+
// reset everything
this.readyState = FileReader.DONE;
this.result = null;
-
+
// set error
var error = new FileError();
error.code = error.ABORT_ERR;
@@ -220,10 +220,10 @@ var FileReader = FileReader || (function() {
*/
FileReader.prototype.readAsText = function(file, encoding) {
var event;
-
+
// Use UTF-8 as default encoding
var enc = encoding ? encoding : "UTF-8";
-
+
// start
this.readyState = FileReader.LOADING;
if (typeof this.onloadstart == "function") {
@@ -234,7 +234,7 @@ var FileReader = FileReader || (function() {
// read and encode file
this.fileName = file.fullPath;
var me = this;
- navigator.fileMgr.readAsText(file.fullPath, enc,
+ navigator.fileMgr.readAsText(file.fullPath, enc,
// success callback
function(result) {
@@ -267,7 +267,7 @@ var FileReader = FileReader || (function() {
var err = new FileError();
err.code = error;
me.error = err;
-
+
// error procedure
me.result = null;
if (typeof me.onerror == "function") {
@@ -292,18 +292,18 @@ var FileReader = FileReader || (function() {
*/
FileReader.prototype.readAsDataURL = function(file) {
var event;
-
+
// start
this.readyState = FileReader.LOADING;
if (typeof this.onloadstart == "function") {
event = {"type":"loadstart", "target":this};
this.onloadstart(event);
}
-
+
// read and encode file
this.fileName = file.fullPath;
var me = this;
- navigator.fileMgr.readAsDataURL(file.fullPath,
+ navigator.fileMgr.readAsDataURL(file.fullPath,
// success callback
function(result) {
@@ -336,7 +336,7 @@ var FileReader = FileReader || (function() {
var err = new FileError();
err.code = error;
me.error = err;
-
+
// error procedure
me.result = null;
if (typeof me.onerror == "function") {
@@ -351,7 +351,7 @@ var FileReader = FileReader || (function() {
}
);
};
-
+
/**
* Read file and return data as a binary data.
*
@@ -385,7 +385,7 @@ var FileReader = FileReader || (function() {
/**
* FileWriter
- *
+ *
* Writes files to the device file system.
*/
var FileWriter = FileWriter || (function() {
@@ -396,12 +396,12 @@ var FileWriter = FileWriter || (function() {
function FileWriter(file) {
this.fileName = file.fullPath || null;
this.length = file.size || 0;
-
+
// default is to write at the beginning of the file
this.position = 0;
-
+
this.readyState = 0; // EMPTY
-
+
// Error
this.error = null;
@@ -420,18 +420,18 @@ var FileWriter = FileWriter || (function() {
FileWriter.INIT = 0;
FileWriter.WRITING = 1;
FileWriter.DONE = 2;
-
+
/**
* Abort writing file.
*/
FileWriter.prototype.abort = function() {
var event;
- // check for invalid state
+ // check for invalid state
if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
throw FileError.INVALID_STATE_ERR;
}
-
+
// set error
var error = new FileError();
error.code = error.ABORT_ERR;
@@ -449,17 +449,17 @@ var FileWriter = FileWriter || (function() {
// set state
this.readyState = FileWriter.DONE;
-
+
// done
if (typeof this.writeend == "function") {
event = {"type":"writeend", "target":this};
this.writeend(event);
}
- };
+ };
/**
* Sets the file position at which the next write will occur.
- *
+ *
* @param offset Absolute byte offset into the file
*/
FileWriter.prototype.seek = function(offset) {
@@ -471,34 +471,34 @@ var FileWriter = FileWriter || (function() {
if (!offset) {
return;
}
-
+
// offset is bigger than file size, set to length of file
- if (offset > this.length) {
+ if (offset > this.length) {
this.position = this.length;
}
// seek back from end of file
- else if (offset < 0) {
+ else if (offset < 0) {
this.position = Math.max(offset + this.length, 0);
- }
+ }
// offset in the middle of file
else {
this.position = offset;
}
};
-
+
/**
* Truncates the file to the specified size.
- *
+ *
* @param size The size to which the file length is to be adjusted
*/
FileWriter.prototype.truncate = function(size) {
var event;
-
+
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw FileError.INVALID_STATE_ERR;
}
-
+
// start
this.readyState = FileWriter.WRITING;
if (typeof this.onwritestart == "function") {
@@ -508,7 +508,7 @@ var FileWriter = FileWriter || (function() {
// truncate file
var me = this;
- navigator.fileMgr.truncate(this.fileName, size,
+ navigator.fileMgr.truncate(this.fileName, size,
// Success callback receives the new file size
function(result) {
// If DONE (canceled), then don't do anything
@@ -555,18 +555,18 @@ var FileWriter = FileWriter || (function() {
event = {"type":"writeend", "target":me};
me.onwriteend(event);
}
- }
+ }
);
};
/**
* Writes the contents of a file to the device.
- *
+ *
* @param data contents to be written
*/
FileWriter.prototype.write = function(data) {
var event;
-
+
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw FileError.INVALID_STATE_ERR;
@@ -643,7 +643,7 @@ var FileWriter = FileWriter || (function() {
var Entry = Entry || (function() {
/**
* Represents a file or directory on the local file system.
- *
+ *
* @param isFile
* {boolean} true if Entry is a file (readonly)
* @param isDirectory
@@ -663,12 +663,12 @@ var Entry = Entry || (function() {
this.isFile = (entry && entry.isFile === true) ? true : false;
this.isDirectory = (entry && entry.isDirectory === true) ? true : false;
this.name = (entry && entry.name) || "";
- this.fullPath = (entry && entry.fullPath) || "";
+ this.fullPath = (entry && entry.fullPath) || "";
};
/**
* Look up the metadata of the entry.
- *
+ *
* @param successCallback
* {Function} is called with a Metadata object
* @param errorCallback
@@ -685,13 +685,13 @@ var Entry = Entry || (function() {
fail = function(error) {
LocalFileSystem.onError(error, errorCallback);
};
-
- PhoneGap.exec(success, fail, "File", "getMetadata", [this.fullPath]);
+
+ Cordova.exec(success, fail, "File", "getMetadata", [this.fullPath]);
};
/**
* Move a file or directory to a new location.
- *
+ *
* @param parent
* {DirectoryEntry} the directory to which to move this entry
* @param newName
@@ -709,18 +709,18 @@ var Entry = Entry || (function() {
// destination path
dstPath,
success = function(entry) {
- var result;
+ var result;
if (entry) {
// create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
+ result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
try {
successCallback(result);
}
catch (e) {
console.log('Error invoking callback: ' + e);
}
- }
+ }
else {
// no Entry object returned
fail(FileError.NOT_FOUND_ERR);
@@ -737,15 +737,15 @@ var Entry = Entry || (function() {
}
// copy
- PhoneGap.exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
+ Cordova.exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
};
/**
* Copy a directory to a different location.
- *
- * @param parent
+ *
+ * @param parent
* {DirectoryEntry} the directory to which to copy the entry
- * @param newName
+ * @param newName
* {DOMString} new name of the entry, defaults to the current name
* @param successCallback
* {Function} called with the new Entry object
@@ -759,18 +759,18 @@ var Entry = Entry || (function() {
name = newName || this.name,
// success callback
success = function(entry) {
- var result;
+ var result;
if (entry) {
// create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
+ result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
try {
successCallback(result);
}
catch (e) {
console.log('Error invoking callback: ' + e);
- }
- }
+ }
+ }
else {
// no Entry object returned
fail(FileError.NOT_FOUND_ERR);
@@ -787,12 +787,12 @@ var Entry = Entry || (function() {
}
// copy
- PhoneGap.exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
+ Cordova.exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
};
/**
* Return a URI that can be used to identify this entry.
- *
+ *
* @param mimeType
* {DOMString} for a FileEntry, the mime type to be used to
* interpret the file, when loaded through this URI.
@@ -804,13 +804,13 @@ var Entry = Entry || (function() {
Entry.prototype.toURI = function(mimeType, successCallback, errorCallback) {
// fullPath attribute contains the full URI on BlackBerry
return this.fullPath;
- };
+ };
/**
* Remove a file or directory. It is an error to attempt to delete a
* directory that is not empty. It is an error to attempt to delete a
* root directory of a file system.
- *
+ *
* @param successCallback {Function} called with no parameters
* @param errorCallback {Function} called with a FileError
*/
@@ -818,18 +818,18 @@ var Entry = Entry || (function() {
var path = this.fullPath,
// directory contents
contents = [];
-
+
// file
if (blackberry.io.file.exists(path)) {
try {
blackberry.io.file.deleteFile(path);
if (typeof successCallback === "function") {
successCallback();
- }
+ }
}
catch (e) {
// permissions don't allow
- LocalFileSystem.onError(FileError.INVALID_MODIFICATION_ERR, errorCallback);
+ LocalFileSystem.onError(FileError.INVALID_MODIFICATION_ERR, errorCallback);
}
}
// directory
@@ -867,42 +867,42 @@ var Entry = Entry || (function() {
/**
* Look up the parent DirectoryEntry of this entry.
- *
+ *
* @param successCallback {Function} called with the parent DirectoryEntry object
* @param errorCallback {Function} called with a FileError
*/
Entry.prototype.getParent = function(successCallback, errorCallback) {
var that = this;
-
+
try {
- // On BlackBerry, the TEMPORARY file system is actually a temporary
+ // On BlackBerry, the TEMPORARY file system is actually a temporary
// directory that is created on a per-application basis. This is
// to help ensure that applications do not share the same temporary
// space. So we check to see if this is the TEMPORARY file system
// (directory). If it is, we must return this Entry, rather than
// the Entry for its parent.
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0,
- function(fileSystem) {
+ function(fileSystem) {
if (fileSystem.root.fullPath === that.fullPath) {
successCallback(fileSystem.root);
}
else {
window.resolveLocalFileSystemURI(
- blackberry.io.dir.getParentDirectory(that.fullPath),
- successCallback,
+ blackberry.io.dir.getParentDirectory(that.fullPath),
+ successCallback,
errorCallback);
}
},
function (error) {
LocalFileSystem.onError(error, errorCallback);
});
- }
+ }
catch (e) {
// FIXME: need a generic error code
LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
}
};
-
+
return Entry;
}());
@@ -916,13 +916,13 @@ var DirectoryEntry = DirectoryEntry || (function() {
function DirectoryEntry(entry) {
DirectoryEntry.__super__.constructor.apply(this, arguments);
};
-
+
// extend Entry
- PhoneGap.extend(DirectoryEntry, Entry);
-
+ Cordova.extend(DirectoryEntry, Entry);
+
/**
* Create or look up a file.
- *
+ *
* @param path {DOMString}
* either a relative or absolute path from this directory in
* which to look up or create a file
@@ -944,9 +944,9 @@ var DirectoryEntry = DirectoryEntry || (function() {
createEntry = function() {
var path_parts = path.split('/'),
name = path_parts[path_parts.length - 1],
- fileEntry = new FileEntry({name: name,
+ fileEntry = new FileEntry({name: name,
isDirectory: false, isFile: true, fullPath: path});
-
+
// invoke success callback
if (typeof successCallback === 'function') {
successCallback(fileEntry);
@@ -974,16 +974,16 @@ var DirectoryEntry = DirectoryEntry || (function() {
LocalFileSystem.onError(FileError.ENCODING_ERR, errorCallback);
return;
}
-
+
// path is a file
if (exists) {
if (create && exclusive) {
// can't guarantee exclusivity
- LocalFileSystem.onError(FileError.PATH_EXISTS_ERR, errorCallback);
+ LocalFileSystem.onError(FileError.PATH_EXISTS_ERR, errorCallback);
}
else {
// create entry for existing file
- createEntry();
+ createEntry();
}
}
// will return true if path exists AND is a directory
@@ -1008,12 +1008,12 @@ var DirectoryEntry = DirectoryEntry || (function() {
else {
// file doesn't exist
LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
- }
- };
+ }
+ };
/**
* Creates or looks up a directory.
- *
+ *
* @param path
* {DOMString} either a relative or absolute path from this
* directory in which to look up or create a directory
@@ -1036,26 +1036,26 @@ var DirectoryEntry = DirectoryEntry || (function() {
createEntry = function() {
var path_parts = path.split('/'),
name = path_parts[path_parts.length - 1],
- dirEntry = new DirectoryEntry({name: name,
+ dirEntry = new DirectoryEntry({name: name,
isDirectory: true, isFile: false, fullPath: path});
-
+
// invoke success callback
if (typeof successCallback === 'function') {
successCallback(dirEntry);
}
};
-
+
// determine if path is relative or absolute
if (!path) {
LocalFileSystem.onError(FileError.ENCODING_ERR, errorCallback);
return;
- }
+ }
else if (path.indexOf(this.fullPath) !== 0) {
// path does not begin with the fullPath of this directory
// therefore, it is relative
path = this.fullPath + '/' + path;
}
-
+
// determine if directory exists
try {
// will return true if path exists AND is a directory
@@ -1066,16 +1066,16 @@ var DirectoryEntry = DirectoryEntry || (function() {
LocalFileSystem.onError(FileError.ENCODING_ERR, errorCallback);
return;
}
-
+
// path is a directory
if (exists) {
if (create && exclusive) {
// can't guarantee exclusivity
- LocalFileSystem.onError(FileError.PATH_EXISTS_ERR, errorCallback);
+ LocalFileSystem.onError(FileError.PATH_EXISTS_ERR, errorCallback);
}
else {
// create entry for existing directory
- createEntry();
+ createEntry();
}
}
// will return true if path exists AND is a file
@@ -1096,26 +1096,26 @@ var DirectoryEntry = DirectoryEntry || (function() {
}
catch (e) {
// unable to create directory
- LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
+ LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
}
}
// path does not exist, don't create
else {
// directory doesn't exist
LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
- }
+ }
};
/**
* Delete a directory and all of it's contents.
- *
+ *
* @param successCallback {Function} called with no parameters
* @param errorCallback {Function} called with a FileError
*/
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
// we're removing THIS directory
var path = this.fullPath;
-
+
// attempt to delete directory
if (blackberry.io.dir.exists(path)) {
// it is an error to attempt to remove the file system root
@@ -1152,29 +1152,29 @@ var DirectoryEntry = DirectoryEntry || (function() {
function DirectoryReader(path) {
this.path = path || null;
};
-
+
/**
* Creates a new DirectoryReader to read entries from this directory
*/
DirectoryEntry.prototype.createReader = function() {
return new DirectoryReader(this.fullPath);
};
-
+
/**
* Reads the contents of the directory.
* @param successCallback {Function} called with a list of entries
* @param errorCallback {Function} called with a FileError
*/
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var path = this.path,
+ var path = this.path,
// process directory contents
createEntries = function(array) {
var entries, entry, num_entries, i, name, result = [];
-
+
// get objects from JSONArray
try {
entries = JSON.parse(array);
- }
+ }
catch (e) {
console.log('unable to parse JSON: ' + e);
LocalFileSystem.onError(FileError.SYNTAX_ERR, errorCallback);
@@ -1193,7 +1193,7 @@ var DirectoryEntry = DirectoryEntry || (function() {
// if name ends with '/', it's a directory
if (/\/$/.test(name) === true) {
// trim file separator
- name = name.substring(0, name.length - 1);
+ name = name.substring(0, name.length - 1);
entry = new DirectoryEntry({
name: name,
fullPath: path + name,
@@ -1213,20 +1213,20 @@ var DirectoryEntry = DirectoryEntry || (function() {
}
try {
successCallback(result);
- }
+ }
catch (e) {
console.log("Error invoking callback: " + e);
}
- };
-
+ };
+
// sanity check
if (!blackberry.io.dir.exists(path)) {
LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
return;
}
-
+
// list directory contents
- PhoneGap.exec(createEntries, errorCallback, "File", "readEntries", [path]);
+ Cordova.exec(createEntries, errorCallback, "File", "readEntries", [path]);
};
return DirectoryEntry;
@@ -1242,14 +1242,14 @@ var FileEntry = FileEntry || (function() {
function FileEntry(entry) {
FileEntry.__super__.constructor.apply(this, arguments);
};
-
+
// extend Entry
- PhoneGap.extend(FileEntry, Entry);
-
+ Cordova.extend(FileEntry, Entry);
+
/**
* Creates a new FileWriter associated with the file that this FileEntry
* represents.
- *
+ *
* @param successCallback
* {Function} called with the new FileWriter
* @param errorCallback
@@ -1263,17 +1263,17 @@ var FileEntry = FileEntry || (function() {
try {
writer = new FileWriter(file);
successCallback(writer);
- }
+ }
catch (e) {
console.log("Error invoking callback: " + e);
- }
+ }
}, errorCallback);
};
/**
* Returns a File that represents the current state of the file that this
* FileEntry represents.
- *
+ *
* @param successCallback
* {Function} called with the new File object
* @param errorCallback
@@ -1290,15 +1290,15 @@ var FileEntry = FileEntry || (function() {
file.name = this.name;
file.fullPath = this.fullPath;
file.type = properties.mimeType;
- file.lastModifiedDate = properties.dateModified;
+ file.lastModifiedDate = properties.dateModified;
file.size = properties.size;
-
+
try {
successCallback(file);
}
catch (e) {
- console.log("Error invoking callback: " + e);
- }
+ console.log("Error invoking callback: " + e);
+ }
}
// entry is a directory
else if (blackberry.io.dir.exists(this.fullPath)) {
@@ -1306,8 +1306,8 @@ var FileEntry = FileEntry || (function() {
}
// entry has been deleted
else {
- LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
- }
+ LocalFileSystem.onError(FileError.NOT_FOUND_ERR, errorCallback);
+ }
};
return FileEntry;
@@ -1315,7 +1315,7 @@ var FileEntry = FileEntry || (function() {
/**
* An interface representing a file system
- *
+ *
* name {DOMString} unique name of the file system (readonly)
* root {DirectoryEntry} directory of the file system (readonly)
*/
@@ -1326,7 +1326,7 @@ function FileSystem() {
/**
* Information about the state of the file or directory.
- *
+ *
* modificationTime {Date} (readonly)
*/
function Metadata() {
@@ -1335,7 +1335,7 @@ function Metadata() {
/**
* Supplies arguments to methods that lookup or create files and directories.
- *
+ *
* @param create
* {boolean} file or directory if it doesn't exist
* @param exclusive
@@ -1363,10 +1363,10 @@ var File = (function() {
this.name = null;
this.fullPath = null;
this.type = null;
- this.lastModifiedDate = null;
+ this.lastModifiedDate = null;
this.size = 0;
};
-
+
return File;
}());
@@ -1374,7 +1374,7 @@ var File = (function() {
* Represents a local file system.
*/
var LocalFileSystem = LocalFileSystem || (function() {
-
+
/**
* Define file system types.
*/
@@ -1382,7 +1382,7 @@ var LocalFileSystem = LocalFileSystem || (function() {
TEMPORARY: 0, // temporary, with no guarantee of persistence
PERSISTENT: 1 // persistent
};
-
+
/**
* Static method for invoking error callbacks.
* @param error FileError code
@@ -1393,21 +1393,21 @@ var LocalFileSystem = LocalFileSystem || (function() {
err.code = error;
try {
errorCallback(err);
- }
+ }
catch (e) {
console.log('Error invoking callback: ' + e);
- }
+ }
};
-
+
/**
- * Utility method to determine if the specified path is the root file
+ * Utility method to determine if the specified path is the root file
* system path.
* @param path fully qualified path
*/
LocalFileSystem.isFileSystemRoot = function(path) {
- return PhoneGap.exec(null, null, "File", "isFileSystemRoot", [path]);
+ return Cordova.exec(null, null, "File", "isFileSystemRoot", [path]);
};
-
+
/**
* Request a file system in which to store application data.
* @param type local file system type
@@ -1423,18 +1423,18 @@ var LocalFileSystem = LocalFileSystem || (function() {
if (file_system) {
// grab the name from the file system object
result = {
- name: file_system.name || null
+ name: file_system.name || null
};
-
+
// create Entry object from file system root
- result.root = new DirectoryEntry(file_system.root);
+ result.root = new DirectoryEntry(file_system.root);
try {
successCallback(result);
}
catch (e) {
console.log('Error invoking callback: ' + e);
- }
- }
+ }
+ }
else {
// no FileSystem object returned
fail(FileError.NOT_FOUND_ERR);
@@ -1444,31 +1444,31 @@ var LocalFileSystem = LocalFileSystem || (function() {
fail = function(error) {
LocalFileSystem.onError(error, errorCallback);
};
-
- PhoneGap.exec(success, fail, "File", "requestFileSystem", [type, size]);
+
+ Cordova.exec(success, fail, "File", "requestFileSystem", [type, size]);
};
-
+
/**
* Look up file system Entry referred to by local URI.
- * @param {DOMString} uri URI referring to a local file or directory
+ * @param {DOMString} uri URI referring to a local file or directory
* @param successCallback invoked with Entry object corresponding to URI
* @param errorCallback invoked if error occurs retrieving file system entry
*/
var _resolveLocalFileSystemURI = function(uri, successCallback, errorCallback) {
// if successful, return either a file or directory entry
var success = function(entry) {
- var result;
+ var result;
if (entry) {
// create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
+ result = (entry.isDirectory) ? new DirectoryEntry(entry) : new FileEntry(entry);
try {
successCallback(result);
}
catch (e) {
console.log('Error invoking callback: ' + e);
- }
- }
+ }
+ }
else {
// no Entry object returned
fail(FileError.NOT_FOUND_ERR);
@@ -1479,13 +1479,13 @@ var LocalFileSystem = LocalFileSystem || (function() {
var fail = function(error) {
LocalFileSystem.onError(error, errorCallback);
};
- PhoneGap.exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
- };
+ Cordova.exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
+ };
/**
* Add the FileSystem interface into the browser.
*/
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
if(typeof window.requestFileSystem === "undefined") {
window.requestFileSystem = _requestFileSystem;
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/filetransfer.js
----------------------------------------------------------------------
diff --git a/javascript/filetransfer.js b/javascript/filetransfer.js
index 25eea12..ee3cc42 100644
--- a/javascript/filetransfer.js
+++ b/javascript/filetransfer.js
@@ -110,7 +110,7 @@ var FileTransfer = FileTransfer || (function() {
}
}
- PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'upload',
+ Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'upload',
[ filePath, server, fileKey, fileName, mimeType, params, debug,
chunkedMode ]);
};
@@ -136,7 +136,7 @@ var FileTransfer = FileTransfer || (function() {
successCallback(entry);
}
};
- PhoneGap.exec(castSuccess, errorCallback, 'FileTransfer',
+ Cordova.exec(castSuccess, errorCallback, 'FileTransfer',
'download', [ source, target ]);
};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/geolocation.js
----------------------------------------------------------------------
diff --git a/javascript/geolocation.js b/javascript/geolocation.js
index d4df1ca..c8d7bc1 100644
--- a/javascript/geolocation.js
+++ b/javascript/geolocation.js
@@ -35,7 +35,7 @@ PositionError.TIMEOUT = 3;
/**
* navigator._geo
- *
+ *
* Provides access to device GPS.
*/
var Geolocation = Geolocation || (function() {
@@ -50,7 +50,7 @@ var Geolocation = Geolocation || (function() {
// Geolocation listeners
this.listeners = {};
};
-
+
/**
* Acquires the current geo position.
*
@@ -64,18 +64,18 @@ var Geolocation = Geolocation || (function() {
if (navigator._geo.listeners[id]) {
console.log("Geolocation Error: Still waiting for previous getCurrentPosition() request.");
try {
- errorCallback(new PositionError(PositionError.TIMEOUT,
+ errorCallback(new PositionError(PositionError.TIMEOUT,
"Geolocation Error: Still waiting for previous getCurrentPosition() request."));
} catch (e) {
}
return;
}
-
- // default maximumAge value should be 0, and set if positive
+
+ // default maximumAge value should be 0, and set if positive
var maximumAge = 0;
// default timeout value should be infinity, but that's a really long time
- var timeout = 3600000;
+ var timeout = 3600000;
var enableHighAccuracy = false;
if (options) {
@@ -90,12 +90,12 @@ var Geolocation = Geolocation || (function() {
}
}
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
- PhoneGap.exec(null, errorCallback, "Geolocation", "getCurrentPosition",
+ Cordova.exec(null, errorCallback, "Geolocation", "getCurrentPosition",
[id, maximumAge, timeout, enableHighAccuracy]);
};
/**
- * Monitors changes to geo position. When a change occurs, the successCallback
+ * Monitors changes to geo position. When a change occurs, the successCallback
* is invoked with the new location.
*
* @param {Function} successCallback The function to call each time the location data is available
@@ -105,13 +105,13 @@ var Geolocation = Geolocation || (function() {
*/
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) {
- // default maximumAge value should be 0, and set if positive
+ // default maximumAge value should be 0, and set if positive
var maximumAge = 0;
- // DO NOT set timeout to a large value for watchPosition in BlackBerry.
- // The interval used for updates is half the timeout value, so a large
+ // DO NOT set timeout to a large value for watchPosition in BlackBerry.
+ // The interval used for updates is half the timeout value, so a large
// timeout value will mean a long wait for the first location.
- var timeout = 10000;
+ var timeout = 10000;
var enableHighAccuracy = false;
if (options) {
@@ -125,9 +125,9 @@ var Geolocation = Geolocation || (function() {
timeout = (options.timeout < 0) ? 0 : options.timeout;
}
}
- var id = PhoneGap.createUUID();
+ var id = Cordova.createUUID();
navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
- PhoneGap.exec(null, errorCallback, "Geolocation", "watchPosition",
+ Cordova.exec(null, errorCallback, "Geolocation", "watchPosition",
[id, maximumAge, timeout, enableHighAccuracy]);
return id;
};
@@ -138,7 +138,7 @@ var Geolocation = Geolocation || (function() {
Geolocation.prototype.success = function(id, result) {
var p = result.message;
- var coords = new Coordinates(p.latitude, p.longitude, p.altitude,
+ var coords = new Coordinates(p.latitude, p.longitude, p.altitude,
p.accuracy, p.heading, p.speed, p.alt_accuracy);
var loc = new Position(coords, p.timestamp);
try {
@@ -181,23 +181,23 @@ var Geolocation = Geolocation || (function() {
* @param {String} id The ID of the watch returned from #watchPosition
*/
Geolocation.prototype.clearWatch = function(id) {
- PhoneGap.exec(null, null, "Geolocation", "stop", [id]);
+ Cordova.exec(null, null, "Geolocation", "stop", [id]);
delete navigator._geo.listeners[id];
};
/**
- * Is PhoneGap implementation being used.
+ * Is Cordova implementation being used.
*/
- var usingPhoneGap = false;
-
+ var usingCordova = false;
+
/**
- * Force PhoneGap implementation to override navigator.geolocation.
+ * Force Cordova implementation to override navigator.geolocation.
*/
- var usePhoneGap = function() {
- if (usingPhoneGap) {
+ var useCordova = function() {
+ if (usingCordova) {
return;
}
- usingPhoneGap = true;
+ usingCordova = true;
// Set built-in geolocation methods to our own implementations
// (Cannot replace entire geolocation, but can replace individual methods)
@@ -211,20 +211,20 @@ var Geolocation = Geolocation || (function() {
/**
* Define navigator.geolocation object.
*/
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
navigator._geo = new Geolocation();
- // if no native geolocation object, use PhoneGap geolocation
+ // if no native geolocation object, use Cordova geolocation
if (typeof navigator.geolocation === 'undefined') {
navigator.geolocation = navigator._geo;
- usingPhoneGap = true;
+ usingCordova = true;
}
});
-
+
/**
* Enable developers to override browser implementation.
*/
return {
- usePhoneGap: usePhoneGap
+ useCordova: useCordova
};
}());
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/network.js
----------------------------------------------------------------------
diff --git a/javascript/network.js b/javascript/network.js
index 5234337..b25562f 100644
--- a/javascript/network.js
+++ b/javascript/network.js
@@ -55,21 +55,21 @@ Connection = {
function(info) {
me.type = info.type;
if (typeof info.event !== "undefined") {
- PhoneGap.fireDocumentEvent(info.event);
+ Cordova.fireDocumentEvent(info.event);
}
// should only fire this once
if (me._firstRun) {
me._firstRun = false;
- PhoneGap.onPhoneGapConnectionReady.fire();
+ Cordova.onCordovaConnectionReady.fire();
}
},
function(e) {
- // If we can't get the network info we should still tell PhoneGap
+ // If we can't get the network info we should still tell Cordova
// to fire the deviceready event.
if (me._firstRun) {
me._firstRun = false;
- PhoneGap.onPhoneGapConnectionReady.fire();
+ Cordova.onCordovaConnectionReady.fire();
}
console.log("Error initializing Network Connection: " + e);
});
@@ -83,13 +83,13 @@ Connection = {
*/
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
// Get info
- PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
+ Cordova.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
};
/**
* Define navigator.network and navigator.network.connection objects
*/
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
navigator.network = new Object();
navigator.network.connection = new NetworkConnection();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/notification.js
----------------------------------------------------------------------
diff --git a/javascript/notification.js b/javascript/notification.js
index b0616ff..bb53046 100644
--- a/javascript/notification.js
+++ b/javascript/notification.js
@@ -20,7 +20,7 @@
/**
* navigator.notification
- *
+ *
* Provides access to notifications on the device.
*/
(function() {
@@ -30,7 +30,7 @@
if (typeof navigator.notification !== "undefined") {
return;
}
-
+
/**
* @constructor
*/
@@ -48,14 +48,14 @@
message = 'Please wait...';
}
- PhoneGap.exec(null, null, 'Notification', 'activityStart', [title, message]);
+ Cordova.exec(null, null, 'Notification', 'activityStart', [title, message]);
};
/**
* Close an activity dialog
*/
Notification.prototype.activityStop = function() {
- PhoneGap.exec(null, null, 'Notification', 'activityStop', []);
+ Cordova.exec(null, null, 'Notification', 'activityStop', []);
};
/**
@@ -68,7 +68,7 @@
Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
var _title = (title || "Alert");
var _buttonLabel = (buttonLabel || "OK");
- PhoneGap.exec(completeCallback, null, 'Notification', 'alert', [message, _title, _buttonLabel]);
+ Cordova.exec(completeCallback, null, 'Notification', 'alert', [message, _title, _buttonLabel]);
};
/**
@@ -91,7 +91,7 @@
Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
var _title = (title || "Confirm");
var _buttonLabels = (buttonLabels || "OK,Cancel");
- return PhoneGap.exec(resultCallback, null, 'Notification', 'confirm', [message, _title, _buttonLabels]);
+ return Cordova.exec(resultCallback, null, 'Notification', 'confirm', [message, _title, _buttonLabels]);
};
/**
@@ -101,14 +101,14 @@
* @param {String} message Message to display in the dialog.
*/
Notification.prototype.progressStart = function(title, message) {
- PhoneGap.exec(null, null, 'Notification', 'progressStart', [title, message]);
+ Cordova.exec(null, null, 'Notification', 'progressStart', [title, message]);
};
/**
* Close the progress dialog.
*/
Notification.prototype.progressStop = function() {
- PhoneGap.exec(null, null, 'Notification', 'progressStop', []);
+ Cordova.exec(null, null, 'Notification', 'progressStop', []);
};
/**
@@ -117,7 +117,7 @@
* @param {Number} value 0-100
*/
Notification.prototype.progressValue = function(value) {
- PhoneGap.exec(null, null, 'Notification', 'progressValue', [value]);
+ Cordova.exec(null, null, 'Notification', 'progressValue', [value]);
};
/**
@@ -125,7 +125,7 @@
* @param {Integer} mills The number of milliseconds to vibrate for.
*/
Notification.prototype.vibrate = function(mills) {
- PhoneGap.exec(null, null, 'Notification', 'vibrate', [mills]);
+ Cordova.exec(null, null, 'Notification', 'vibrate', [mills]);
};
/**
@@ -133,13 +133,13 @@
* @param {Integer} count The number of beeps.
*/
Notification.prototype.beep = function(count) {
- PhoneGap.exec(null, null, 'Notification', 'beep', [count]);
+ Cordova.exec(null, null, 'Notification', 'beep', [count]);
};
/**
* Define navigator.notification object.
*/
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
navigator.notification = new Notification();
- });
+ });
}());
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/playbook/battery.js
----------------------------------------------------------------------
diff --git a/javascript/playbook/battery.js b/javascript/playbook/battery.js
index c195583..2192a94 100644
--- a/javascript/playbook/battery.js
+++ b/javascript/playbook/battery.js
@@ -163,13 +163,13 @@
}
};
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
if (typeof navigator.battery === "undefined") {
navigator.battery = new Battery();
- PhoneGap.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
- PhoneGap.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
- PhoneGap.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
+ Cordova.addWindowEventHandler("batterystatus", navigator.battery.eventHandler);
+ Cordova.addWindowEventHandler("batterylow", navigator.battery.eventHandler);
+ Cordova.addWindowEventHandler("batterycritical", navigator.battery.eventHandler);
}
});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/playbook/playBookPluginManager.js
----------------------------------------------------------------------
diff --git a/javascript/playbook/playBookPluginManager.js b/javascript/playbook/playBookPluginManager.js
index 7d6403d..f543f5c 100644
--- a/javascript/playbook/playBookPluginManager.js
+++ b/javascript/playbook/playBookPluginManager.js
@@ -19,15 +19,15 @@
* Copyright (c) 2011, Research In Motion Limited.
*/
-phonegap.PluginManager = (function (webworksPluginManager) {
+cordova.PluginManager = (function (webworksPluginManager) {
"use strict";
/**
- * Private list of HTML 5 audio objects, indexed by the PhoneGap media object ids
+ * Private list of HTML 5 audio objects, indexed by the Cordova media object ids
*/
var audioObjects = {},
- retInvalidAction = { "status" : PhoneGap.callbackStatus.INVALID_ACTION, "message" : "Action not found" },
- retAsyncCall = { "status" : PhoneGap.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" },
+ retInvalidAction = { "status" : Cordova.callbackStatus.INVALID_ACTION, "message" : "Action not found" },
+ retAsyncCall = { "status" : Cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" },
cameraAPI = {
execute: function (webWorksResult, action, args, win, fail) {
switch (action) {
@@ -41,13 +41,13 @@ phonegap.PluginManager = (function (webworksPluginManager) {
deviceAPI = {
execute: function (webWorksResult, action, args, win, fail) {
if (action === 'getDeviceInfo') {
- return {"status" : PhoneGap.callbackStatus.OK,
+ return {"status" : Cordova.callbackStatus.OK,
"message" : {
"version" : blackberry.system.softwareVersion,
"name" : blackberry.system.model,
"uuid" : blackberry.identity.PIN,
"platform" : "PlayBook",
- "phonegap" : "1.4.1"
+ "cordova" : "1.4.1"
}
};
}
@@ -59,7 +59,7 @@ phonegap.PluginManager = (function (webworksPluginManager) {
switch (action) {
case 'log':
console.log(args);
- return {"status" : PhoneGap.callbackStatus.OK,
+ return {"status" : Cordova.callbackStatus.OK,
"message" : 'Message logged to console: ' + args};
}
return retInvalidAction;
@@ -197,7 +197,7 @@ phonegap.PluginManager = (function (webworksPluginManager) {
case 'getSupportedAudioModes':
case 'getSupportedImageModes':
case 'getSupportedVideoModes':
- return {"status": PhoneGap.callbackStatus.OK, "message": []};
+ return {"status": Cordova.callbackStatus.OK, "message": []};
case 'captureImage':
captureMethod = "takePicture";
captureCB();
@@ -207,7 +207,7 @@ phonegap.PluginManager = (function (webworksPluginManager) {
captureCB();
break;
case 'captureAudio':
- return {"status": PhoneGap.callbackStatus.INVALID_ACTION, "message": "captureAudio is not currently supported"};
+ return {"status": Cordova.callbackStatus.INVALID_ACTION, "message": "captureAudio is not currently supported"};
}
return retAsyncCall;
@@ -237,11 +237,11 @@ phonegap.PluginManager = (function (webworksPluginManager) {
callbackID = blackberry.events.registerEventHandler("networkChange", win);
//pass our callback id down to our network extension
- request = new blackberry.transport.RemoteFunctionCall("com/phonegap/getConnectionInfo");
+ request = new blackberry.transport.RemoteFunctionCall("org/apache/cordova/getConnectionInfo");
request.addParam("networkStatusChangedID", callbackID);
request.makeSyncCall();
- return { "status": PhoneGap.callbackStatus.OK, "message": {"type": connectionType, "event": eventType } };
+ return { "status": Cordova.callbackStatus.OK, "message": {"type": connectionType, "event": eventType } };
}
return retInvalidAction;
}
@@ -253,7 +253,7 @@ phonegap.PluginManager = (function (webworksPluginManager) {
return {"status" : 9, "message" : "Notification action - " + action + " arguments not found"};
}
-
+
//Unpack and map the args
var msg = args[0],
title = args[1],
@@ -284,17 +284,17 @@ phonegap.PluginManager = (function (webworksPluginManager) {
'Notification' : notificationAPI
};
- phonegap.PlayBookPluginManager = function () {
- PhoneGap.onNativeReady.fire();
+ cordova.PlayBookPluginManager = function () {
+ Cordova.onNativeReady.fire();
};
- phonegap.PlayBookPluginManager.prototype.exec = function (win, fail, clazz, action, args) {
+ cordova.PlayBookPluginManager.prototype.exec = function (win, fail, clazz, action, args) {
var wwResult = webworksPluginManager.exec(win, fail, clazz, action, args);
//We got a sync result or a not found from WW that we can pass on to get a native mixin
//For async calls there's nothing to do
- if ((wwResult.status === PhoneGap.callbackStatus.OK ||
- wwResult.status === PhoneGap.callbackStatus.CLASS_NOT_FOUND_EXCEPTION) &&
+ if ((wwResult.status === Cordova.callbackStatus.OK ||
+ wwResult.status === Cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION) &&
plugins[clazz]) {
return plugins[clazz].execute(wwResult.message, action, args, win, fail);
}
@@ -302,10 +302,10 @@ phonegap.PluginManager = (function (webworksPluginManager) {
return wwResult;
};
- phonegap.PlayBookPluginManager.prototype.resume = function () {};
- phonegap.PlayBookPluginManager.prototype.pause = function () {};
- phonegap.PlayBookPluginManager.prototype.destroy = function () {};
+ cordova.PlayBookPluginManager.prototype.resume = function () {};
+ cordova.PlayBookPluginManager.prototype.pause = function () {};
+ cordova.PlayBookPluginManager.prototype.destroy = function () {};
//Instantiate it
- return new phonegap.PlayBookPluginManager();
-}(new phonegap.WebWorksPluginManager()));
+ return new cordova.PlayBookPluginManager();
+}(new cordova.WebWorksPluginManager()));
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/javascript/webWorksPluginManager.js
----------------------------------------------------------------------
diff --git a/javascript/webWorksPluginManager.js b/javascript/webWorksPluginManager.js
index 68e6c7b..b35e97a 100644
--- a/javascript/webWorksPluginManager.js
+++ b/javascript/webWorksPluginManager.js
@@ -18,27 +18,27 @@
* under the License.
* Copyright (c) 2011, Research In Motion Limited.
*/
-
- //BlackBerry attaches the Java plugin manager at phonegap.PluginManager, we go to the same
+
+ //BlackBerry attaches the Java plugin manager at cordova.PluginManager, we go to the same
//spot for compatibility
-if (!window.phonegap) { window.phonegap = {}; }
+if (!window.cordova) { window.cordova = {}; }
(function () {
"use strict";
- var retAsyncCall = { "status" : PhoneGap.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" },
- retInvalidAction = { "status" : PhoneGap.callbackStatus.INVALID_ACTION, "message" : "Action not found" },
+ var retAsyncCall = { "status" : Cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" },
+ retInvalidAction = { "status" : Cordova.callbackStatus.INVALID_ACTION, "message" : "Action not found" },
// Define JavaScript plugin implementations that are common across
// WebWorks platforms (phone/tablet).
plugins = {};
- phonegap.WebWorksPluginManager = function () {
+ cordova.WebWorksPluginManager = function () {
};
- phonegap.WebWorksPluginManager.prototype.exec = function (win, fail, clazz, action, args) {
+ cordova.WebWorksPluginManager.prototype.exec = function (win, fail, clazz, action, args) {
if (plugins[clazz]) {
return plugins[clazz].execute(action, args, win, fail);
}
- return {"status" : PhoneGap.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message" : "Class " + clazz + " cannot be found"};
+ return {"status" : Cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message" : "Class " + clazz + " cannot be found"};
};
}());
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/dist/README.md
----------------------------------------------------------------------
diff --git a/template/dist/README.md b/template/dist/README.md
index 96dd3df..46608d0 100644
--- a/template/dist/README.md
+++ b/template/dist/README.md
@@ -1,4 +1,4 @@
-PhoneGap BlackBerry WebWorks Distribution
+Cordova BlackBerry WebWorks Distribution
=========================================
Directory Structure
@@ -25,12 +25,12 @@ Barebones Projects
`www/config.xml` is a sample that you are free to alter.
-The necessary PhoneGap sections are `<feature>` and `<access>`:
+The necessary Cordova sections are `<feature>` and `<access>`:
- <!-- PhoneGap API -->
+ <!-- Cordova API -->
<feature ... />
<feature ... />
- <!-- PhoneGap API -->
+ <!-- Cordova API -->
+ <access ... />
<access ... />
- <access ... />
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/plugin/build.xml
----------------------------------------------------------------------
diff --git a/template/plugin/build.xml b/template/plugin/build.xml
index d38324e..17093cb 100644
--- a/template/plugin/build.xml
+++ b/template/plugin/build.xml
@@ -1,4 +1,4 @@
-<project name="Package PhoneGap BlackBerry WebWorks Plugin" default="help">
+<project name="Package Cordova BlackBerry WebWorks Plugin" default="help">
<!-- LOAD PROPERTIES -->
@@ -71,7 +71,7 @@ SYNOPSIS
ant COMMAND [-D<argument>=<value>]...
DESCRIPTION
- You can package your plugin for use in PhoneGap BlackBerry WebWorks projects.
+ You can package your plugin for use in Cordova BlackBerry WebWorks projects.
COMMANDS
help .............. Show this help menu.
@@ -89,4 +89,4 @@ GETTING STARTED
2. <ant build> to package your plugin for distribution
</echo>
</target>
-</project>
\ No newline at end of file
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/plugin/src/com/phonegap/plugins/Example.java
----------------------------------------------------------------------
diff --git a/template/plugin/src/com/phonegap/plugins/Example.java b/template/plugin/src/com/phonegap/plugins/Example.java
index cee821f..e13aab7 100644
--- a/template/plugin/src/com/phonegap/plugins/Example.java
+++ b/template/plugin/src/com/phonegap/plugins/Example.java
@@ -1,7 +1,7 @@
-package com.phonegap.plugins;
+package org.apache.cordova.plugins;
-import com.phonegap.api.Plugin;
-import com.phonegap.api.PluginResult;
+import org.apache.cordova.api.Plugin;
+import org.apache.cordova.api.PluginResult;
import org.json.me.JSONArray;
@@ -39,4 +39,4 @@ public class Example extends Plugin {
public void onDestroy() {
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/plugin/src/com/phonegap/plugins/ExampleAction.java
----------------------------------------------------------------------
diff --git a/template/plugin/src/com/phonegap/plugins/ExampleAction.java b/template/plugin/src/com/phonegap/plugins/ExampleAction.java
index a98aa7b..6da660e 100644
--- a/template/plugin/src/com/phonegap/plugins/ExampleAction.java
+++ b/template/plugin/src/com/phonegap/plugins/ExampleAction.java
@@ -1,6 +1,6 @@
-package com.phonegap.plugins;
+package org.apache.cordova.plugins;
-import com.phonegap.api.PluginResult;
+import org.apache.cordova.api.PluginResult;
import org.json.me.JSONArray;
import org.json.me.JSONException;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/plugin/www/javascript/example.js
----------------------------------------------------------------------
diff --git a/template/plugin/www/javascript/example.js b/template/plugin/www/javascript/example.js
index 54539c0..952abbf 100644
--- a/template/plugin/www/javascript/example.js
+++ b/template/plugin/www/javascript/example.js
@@ -3,7 +3,7 @@
*
* window.plugins.example.echo(
* // argument passed to the native plugin
- * 'Hello PhoneGap',
+ * 'Hello Cordova',
*
* // success callback
* function(response) {
@@ -20,16 +20,13 @@
var Example = function() {
return {
echo: function(message, successCallback, errorCallback) {
- PhoneGap.exec(successCallback, errorCallback, 'Example', 'echo', [ message ]);
+ Cordova.exec(successCallback, errorCallback, 'Example', 'echo', [ message ]);
}
}
};
- PhoneGap.addConstructor(function() {
+ Cordova.addConstructor(function() {
// add plugin to window.plugins
- PhoneGap.addPlugin('example', new Example());
-
- // register plugin on native side
- phonegap.PluginManager.addPlugin('Example', 'com.phonegap.plugins.Example');
+ Cordova.addPlugin('example', new Example());
});
-})();
\ No newline at end of file
+})();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/project/build.xml
----------------------------------------------------------------------
diff --git a/template/project/build.xml b/template/project/build.xml
index 15e3ed6..537ff13 100644
--- a/template/project/build.xml
+++ b/template/project/build.xml
@@ -1,4 +1,4 @@
-<project name="Build and Deploy a PhoneGap BlackBerry WebWorks Project" default="help">
+<project name="Build and Deploy a Cordova BlackBerry WebWorks Project" default="help">
<!-- LOAD ANT-CONTRIB LIBRARY -->
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/project/playbook.xml
----------------------------------------------------------------------
diff --git a/template/project/playbook.xml b/template/project/playbook.xml
index 9518211..5ca5ac3 100644
--- a/template/project/playbook.xml
+++ b/template/project/playbook.xml
@@ -20,11 +20,11 @@
</and>
</condition>
- <condition property="bbwp" value="${properties.playbook.bbwp.dir}/bbwp/bbwp" else="${properties.playbook.bbwp.dir}/bbwp/bbwp.exe">
+ <condition property="bbwp" value="${properties.playbook.bbwp.dir}/bbwp" else="${properties.playbook.bbwp.dir}/bbwp.exe">
<equals arg1="${isMacOSX}" arg2="true" />
</condition>
- <condition property="blackberry-deploy" value="${properties.playbook.bbwp.dir}/bbwp/blackberry-tablet-sdk/bin/blackberry-deploy" else="${properties.playbook.bbwp.dir}/bbwp/blackberry-tablet-sdk/bin/blackberry-deploy.bat">
+ <condition property="blackberry-deploy" value="${properties.playbook.bbwp.dir}/blackberry-tablet-sdk/bin/blackberry-deploy" else="${properties.playbook.bbwp.dir}/blackberry-tablet-sdk/bin/blackberry-deploy.bat">
<equals arg1="${isMacOSX}" arg2="true" />
</condition>
@@ -76,7 +76,7 @@
</fileset>
</copy>
- <!-- Overwrite the phonegap js with the playbook specific phonegap js -->
+ <!-- Overwrite the cordova js with the playbook specific cordova js -->
<copy todir="${widget.dir}" overwrite="true">
<fileset dir="www/playbook">
<include name="*.js" />
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/project/www/config.xml
----------------------------------------------------------------------
diff --git a/template/project/www/config.xml b/template/project/www/config.xml
index e1084d3..e03e98d 100644
--- a/template/project/www/config.xml
+++ b/template/project/www/config.xml
@@ -9,18 +9,18 @@
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0">
- <name>PhoneGap Sample</name>
+ <name>Cordova Sample</name>
<description>
- A sample application written with PhoneGap.
+ A sample application written with Cordova.
</description>
<license href="http://opensource.org/licenses/alphabetical">
</license>
- <!-- PhoneGap API -->
+ <!-- Cordova API -->
<feature id="blackberry.system" required="true" version="1.0.0.0" />
- <feature id="com.phonegap" required="true" version="1.0.0" />
+ <feature id="org.apache.cordova" required="true" version="1.0.0" />
<feature id="blackberry.find" required="true" version="1.0.0.0" />
<feature id="blackberry.identity" required="true" version="1.0.0.0" />
<feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
@@ -35,7 +35,7 @@
<feature id="blackberry.media.camera" />
<feature id="blackberry.ui.dialog" />
- <!-- PhoneGap API -->
+ <!-- Cordova API -->
<access subdomains="true" uri="file:///store/home" />
<access subdomains="true" uri="file:///SDCard" />
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/project/www/index.html
----------------------------------------------------------------------
diff --git a/template/project/www/index.html b/template/project/www/index.html
index ff1dae6..3358d9f 100644
--- a/template/project/www/index.html
+++ b/template/project/www/index.html
@@ -23,11 +23,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=no">
<script src="json2.js" type="text/javascript"></script>
- <script src="phonegap.js" type="text/javascript"></script>
+ <script src="cordova.js" type="text/javascript"></script>
<script type="text/javascript">
//---------------------------------------------------------------------
- // PhoneGap event listeners
+ // Cordova event listeners
//---------------------------------------------------------------------
// invoked when device is ready
@@ -35,7 +35,7 @@
document.getElementById('window.device.platform').innerHTML = 'window.device.platform = ' + window.device.platform;
document.getElementById('window.device.version').innerHTML = 'window.device.version = ' + window.device.version;
document.getElementById('window.device.uuid').innerHTML = 'window.device.uuid = ' + window.device.uuid;
- document.getElementById('window.device.phonegap').innerHTML = 'window.device.phonegap = ' + window.device.phonegap;
+ document.getElementById('window.device.cordova').innerHTML = 'window.device.cordova = ' + window.device.cordova;
setNetworkType();
}
@@ -62,7 +62,7 @@
setNetworkType();
}
- // register PhoneGap event listeners when DOM content loaded
+ // register Cordova event listeners when DOM content loaded
function init() {
console.log('init()');
document.addEventListener("deviceready", deviceInfo, true);
@@ -217,8 +217,8 @@
'message: ' + error.message + '\n');
}
- function usePhoneGapGeo() {
- Geolocation.usePhoneGap();
+ function useCordovaGeo() {
+ Geolocation.useCordova();
}
//---------------------------------------------------------------------
@@ -504,7 +504,7 @@
// read the file
file = new File();
- file.fullPath = root.toURI() + '/phonegap.txt';
+ file.fullPath = root.toURI() + '/cordova.txt';
fileReader.readAsText(file);
}
@@ -524,7 +524,7 @@
// read the file
file = new File();
- file.fullPath = root.toURI() + '/phonegap.txt';
+ file.fullPath = root.toURI() + '/cordova.txt';
fileReader.readAsDataURL(file);
}
@@ -578,7 +578,7 @@
};
// create a file and write to it
- root.getFile('bbgap.txt', {create: true}, create_writer, onFileSystemError);
+ root.getFile('bbcordova.txt', {create: true}, create_writer, onFileSystemError);
}
// truncates a file
@@ -611,7 +611,7 @@
};
// retrieve a file and truncate it
- root.getFile('bbgap.txt', {create: false}, create_writer, onFileSystemError);
+ root.getFile('bbcordova.txt', {create: false}, create_writer, onFileSystemError);
}
// retrieve root file system
@@ -882,7 +882,7 @@
<p id="window.device.platform">[window.device.platform]</p>
<p id="window.device.version">[window.device.version]</p>
<p id="window.device.uuid">[window.device.uuid]</p>
- <p id="window.device.phonegap">[window.device.phonegap]</p>
+ <p id="window.device.cordova">[window.device.cordova]</p>
<h3>window.notification</h3>
<input type="button" value="Beep" onclick="callBeep();return false;" />
@@ -903,7 +903,7 @@
<input type="button" value="Get Location" onclick="getLocation();return false;" />
<input type="button" value="Watch Location" onclick="watchLocation();return false;" />
<input type="button" value="Clear Geo" onclick="clearLocationWatch();return false;" />
- <input type="button" value="Use PhoneGap" onclick="usePhoneGapGeo();return false;" />
+ <input type="button" value="Use Cordova" onclick="useCordovaGeo();return false;" />
<h3>navigator.accelerometer</h3>
<dl id="accel-data">
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/05319d3c/template/project/www/plugins.xml
----------------------------------------------------------------------
diff --git a/template/project/www/plugins.xml b/template/project/www/plugins.xml
index aad5987..41772da 100644
--- a/template/project/www/plugins.xml
+++ b/template/project/www/plugins.xml
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugins>
- <plugin name="App" value="com.phonegap.app.App"/>
- <plugin name="Device" value="com.phonegap.device.Device"/>
- <plugin name="Camera" value="com.phonegap.camera.Camera"/>
- <plugin name="Network Status" value="com.phonegap.network.Network"/>
- <plugin name="Notification" value="com.phonegap.notification.Notification"/>
- <plugin name="Accelerometer" value="com.phonegap.accelerometer.Accelerometer"/>
- <plugin name="Geolocation" value="com.phonegap.geolocation.Geolocation"/>
- <plugin name="File" value="com.phonegap.file.FileManager"/>
- <plugin name="FileTransfer" value="com.phonegap.http.FileTransfer"/>
- <plugin name="Contact" value="com.phonegap.pim.Contact"/>
- <plugin name="MediaCapture" value="com.phonegap.media.MediaCapture"/>
- <plugin name="Battery" value="com.phonegap.battery.Battery"/>
+ <plugin name="App" value="org.apache.cordova.app.App"/>
+ <plugin name="Device" value="org.apache.cordova.device.Device"/>
+ <plugin name="Camera" value="org.apache.cordova.camera.Camera"/>
+ <plugin name="Network Status" value="org.apache.cordova.network.Network"/>
+ <plugin name="Notification" value="org.apache.cordova.notification.Notification"/>
+ <plugin name="Accelerometer" value="org.apache.cordova.accelerometer.Accelerometer"/>
+ <plugin name="Geolocation" value="org.apache.cordova.geolocation.Geolocation"/>
+ <plugin name="File" value="org.apache.cordova.file.FileManager"/>
+ <plugin name="FileTransfer" value="org.apache.cordova.http.FileTransfer"/>
+ <plugin name="Contact" value="org.apache.cordova.pim.Contact"/>
+ <plugin name="MediaCapture" value="org.apache.cordova.media.MediaCapture"/>
+ <plugin name="Battery" value="org.apache.cordova.battery.Battery"/>
</plugins>