Add docs and fixed to pass through the Google Closure Compiler without warnings

This commit is contained in:
defrex
2011-03-30 12:14:21 -04:00
committed by Fil Maj
parent bdadbbc339
commit bde59adc04
14 changed files with 210 additions and 168 deletions

View File

@@ -9,7 +9,8 @@
if (!PhoneGap.hasResource("accelerometer")) {
PhoneGap.addResource("accelerometer");
Acceleration = function(x, y, z) {
/** @constructor */
function Acceleration(x, y, z) {
this.x = x;
this.y = y;
this.z = z;

View File

@@ -11,6 +11,7 @@ PhoneGap.addResource("app");
/**
* Constructor
* @constructor
*/
App = function() {};
@@ -23,7 +24,7 @@ App.prototype.clearCache = function() {
/**
* Load the url into the webview.
*
*
* @param url The URL to load
* @param props Properties that can be passed in to the activity:
* wait: int => wait msec before loading URL
@@ -33,7 +34,7 @@ App.prototype.clearCache = function() {
* loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
* errorUrl: URL => URL to load if there's an error loading specified URL with loadUrl(). Should be a local URL such as file:///android_asset/www/error.html");
* keepRunning: boolean => enable app to keep running in background
*
*
* Example:
* App app = new App();
* app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
@@ -59,7 +60,7 @@ App.prototype.clearHistory = function() {
/**
* Add a class that implements a service.
*
*
* @param serviceType
* @param className
*/
@@ -70,10 +71,10 @@ App.prototype.addService = function(serviceType, className) {
/**
* Override the default behavior of the Android back button.
* If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
*
*
* Note: The user should not have to call this method. Instead, when the user
* registers for the "backbutton" event, this is automatically done.
*
*
* @param override T=override, F=cancel override
*/
App.prototype.overrideBackbutton = function(override) {

View File

@@ -11,22 +11,23 @@ PhoneGap.addResource("contact");
/**
* Contains information about a single contact.
* @constructor
* @param {DOMString} id unique identifier
* @param {DOMString} displayName
* @param {ContactName} name
* @param {DOMString} nickname
* @param {ContactField[]} phoneNumbers array of phone numbers
* @param {ContactField[]} emails array of email addresses
* @param {ContactAddress[]} addresses array of addresses
* @param {ContactField[]} ims instant messaging user ids
* @param {ContactOrganization[]} organizations
* @param {Array.<ContactField>} phoneNumbers array of phone numbers
* @param {Array.<ContactField>} emails array of email addresses
* @param {Array.<ContactAddress>} addresses array of addresses
* @param {Array.<ContactField>} ims instant messaging user ids
* @param {Array.<ContactOrganization>} organizations
* @param {DOMString} revision date contact was last updated
* @param {DOMString} birthday contact's birthday
* @param {DOMString} gender contact's gender
* @param {DOMString} note user notes about contact
* @param {ContactField[]} photos
* @param {ContactField[]} categories
* @param {ContactField[]} urls contact's web sites
* @param {Array.<ContactField>} photos
* @param {Array.<ContactField>} categories
* @param {Array.<ContactField>} urls contact's web sites
* @param {DOMString} timezone the contacts time zone
*/
var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
@@ -53,7 +54,8 @@ var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, a
/**
* ContactError.
* An error code assigned by an implementation when an error has occurred
* An error code assigned by an implementation when an error has occurreds
* @constructor
*/
var ContactError = function() {
this.code=null;
@@ -152,6 +154,7 @@ Contact.prototype.save = function(successCB, errorCB) {
/**
* Contact name.
* @constructor
* @param formatted
* @param familyName
* @param givenName
@@ -170,6 +173,7 @@ var ContactName = function(formatted, familyName, givenName, middle, prefix, suf
/**
* Generic contact field.
* @constructor
* @param {DOMString} id unique identifier, should only be set by native code
* @param type
* @param value
@@ -184,6 +188,7 @@ var ContactField = function(type, value, pref) {
/**
* Contact address.
* @constructor
* @param {DOMString} id unique identifier, should only be set by native code
* @param formatted
* @param streetAddress
@@ -204,6 +209,7 @@ var ContactAddress = function(formatted, streetAddress, locality, region, postal
/**
* Contact organization.
* @constructor
* @param {DOMString} id unique identifier, should only be set by native code
* @param name
* @param dept
@@ -222,6 +228,7 @@ var ContactOrganization = function(name, dept, title) {
/**
* Represents a group of Contacts.
* @constructor
*/
var Contacts = function() {
this.inProgress = false;
@@ -258,10 +265,10 @@ Contacts.prototype.create = function(properties) {
};
/**
* This function returns and array of contacts. It is required as we need to convert raw
* JSON objects into concrete Contact objects. Currently this method is called after
* This function returns and array of contacts. It is required as we need to convert raw
* JSON objects into concrete Contact objects. Currently this method is called after
* navigator.service.contacts.find but before the find methods success call back.
*
*
* @param jsonArray an array of JSON Objects that need to be converted to Contact objects.
* @returns an array of Contact objects
*/
@@ -277,6 +284,7 @@ Contacts.prototype.cast = function(pluginResult) {
/**
* ContactFindOptions.
* @constructor
* @param filter used to match contacts against
* @param multiple boolean used to determine if more than one contact should be returned
* @param updatedSince return only contact records that have been updated on or after the given time

View File

@@ -11,6 +11,9 @@
if (!PhoneGap.hasResource("crypto")) {
PhoneGap.addResource("crypto");
/**
* @constructor
*/
var Crypto = function() {
};

View File

@@ -11,8 +11,9 @@ PhoneGap.addResource("file");
/**
* This class provides some useful information about a file.
* This is the fields returned when navigator.fileMgr.getFileProperties()
* This is the fields returned when navigator.fileMgr.getFileProperties()
* is called.
* @constructor
*/
FileProperties = function(filePath) {
this.filePath = filePath;
@@ -22,12 +23,13 @@ FileProperties = function(filePath) {
/**
* Represents a single file.
*
* name {DOMString} name of the file, without path information
* fullPath {DOMString} the full path of the file, including the name
* type {DOMString} mime type
* lastModifiedDate {Date} last modified date
* size {Number} size of the file in bytes
*
* @constructor
* @param name {DOMString} name of the file, without path information
* @param fullPath {DOMString} the full path of the file, including the name
* @param type {DOMString} mime type
* @param lastModifiedDate {Date} last modified date
* @param size {Number} size of the file in bytes
*/
File = function(name, fullPath, type, lastModifiedDate, size) {
this.name = name || null;
@@ -37,7 +39,8 @@ File = function(name, fullPath, type, lastModifiedDate, size) {
this.size = size || 0;
};
FileError = function() {
/** @constructor */
function FileError() {
this.code = null;
};
@@ -62,8 +65,9 @@ FileError.PATH_EXISTS_ERR = 12;
// File manager
//-----------------------------------------------------------------------------
FileMgr = function() {
};
/** @constructor */
function FileMgr() {
}
FileMgr.prototype.getFileProperties = function(filePath) {
return PhoneGap.exec(null, null, "File", "getFileProperties", [filePath]);
@@ -126,6 +130,7 @@ PhoneGap.addConstructor(function() {
* For Android:
* The root directory is the root of the file system.
* To read from the SD card, the file name is "sdcard/my_file.txt"
* @constructor
*/
FileReader = function() {
this.fileName = "";
@@ -164,7 +169,7 @@ FileReader.prototype.abort = function() {
var error = new FileError();
error.code = error.ABORT_ERR;
this.error = error;
// If error callback
if (typeof this.onerror === "function") {
this.onerror({"type":"error", "target":this});
@@ -378,7 +383,8 @@ FileReader.prototype.readAsArrayBuffer = function(file) {
* For Android:
* The root directory is the root of the file system.
* To write to the SD card, the file name is "sdcard/my_file.txt"
*
*
* @constructor
* @param file {File} File object containing file properties
* @param append if true write to the end of the file, otherwise overwrite the file
*/
@@ -420,13 +426,13 @@ FileWriter.prototype.abort = function() {
// check for invalid state
if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
throw FileError.INVALID_STATE_ERR;
}
}
// set error
var error = new FileError(), evt;
error.code = error.ABORT_ERR;
this.error = error;
// If error callback
if (typeof this.onerror === "function") {
this.onerror({"type":"error", "target":this});
@@ -435,7 +441,7 @@ FileWriter.prototype.abort = function() {
if (typeof this.onabort === "function") {
this.oneabort({"type":"abort", "target":this});
}
this.readyState = FileWriter.DONE;
// If write end callback
@@ -446,7 +452,7 @@ FileWriter.prototype.abort = function() {
/**
* Writes data to the file
*
*
* @param text to be written
*/
FileWriter.prototype.write = function(text) {
@@ -526,13 +532,13 @@ FileWriter.prototype.write = function(text) {
};
/**
/**
* Moves the file pointer to the location specified.
*
* If the offset is a negative number the position of the file
* pointer is rewound. If the offset is greater than the file
* size the position is set to the end of the file.
*
*
* If the offset is a negative number the position of the file
* pointer is rewound. If the offset is greater than the file
* size the position is set to the end of the file.
*
* @param offset is the location to move the file pointer to.
*/
FileWriter.prototype.seek = function(offset) {
@@ -544,12 +550,12 @@ FileWriter.prototype.seek = function(offset) {
if (!offset) {
return;
}
// See back from end of file.
if (offset < 0) {
this.position = Math.max(offset + this.length, 0);
}
// Offset is bigger then file size so set position
// Offset is bigger then file size so set position
// to the end of the file.
else if (offset > this.length) {
this.position = this.length;
@@ -558,12 +564,12 @@ FileWriter.prototype.seek = function(offset) {
// to start writing.
else {
this.position = offset;
}
}
};
/**
/**
* Truncates the file to the size specified.
*
*
* @param size to chop the file at.
*/
FileWriter.prototype.truncate = function(size) {
@@ -640,7 +646,8 @@ FileWriter.prototype.truncate = function(size) {
);
};
LocalFileSystem = function() {
/** @constructor */
function LocalFileSystem() {
};
// File error codes
@@ -651,7 +658,7 @@ LocalFileSystem.APPLICATION = 3;
/**
* Requests a filesystem in which to store application data.
*
*
* @param {int} type of file system being requested
* @param {Function} successCallback is called with the new FileSystem
* @param {Function} errorCallback is called with a FileError
@@ -670,7 +677,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
};
/**
*
*
* @param {DOMString} uri referring to a local file in a filesystem
* @param {Function} successCallback is called with the new entry
* @param {Function} errorCallback is called with a FileError
@@ -680,12 +687,12 @@ LocalFileSystem.prototype.resolveLocalFileSystemURI = function(uri, successCallb
};
/**
* This function returns and array of contacts. It is required as we need to convert raw
* JSON objects into concrete Contact objects. Currently this method is called after
* This function returns and array of contacts. It is required as we need to convert raw
* JSON objects into concrete Contact objects. Currently this method is called after
* navigator.service.contacts.find but before the find methods success call back.
*
*
* @param a JSON Objects that need to be converted to DirectoryEntry or FileEntry objects.
* @returns an entry
* @returns an entry
*/
LocalFileSystem.prototype._castFS = function(pluginResult) {
var entry = null;
@@ -695,7 +702,7 @@ LocalFileSystem.prototype._castFS = function(pluginResult) {
entry.name = pluginResult.message.root.name;
entry.fullPath = pluginResult.message.root.fullPath;
pluginResult.message.root = entry;
return pluginResult;
return pluginResult;
}
LocalFileSystem.prototype._castEntry = function(pluginResult) {
@@ -713,17 +720,17 @@ LocalFileSystem.prototype._castEntry = function(pluginResult) {
entry.name = pluginResult.message.name;
entry.fullPath = pluginResult.message.fullPath;
pluginResult.message = entry;
return pluginResult;
return pluginResult;
}
LocalFileSystem.prototype._castEntries = function(pluginResult) {
var entries = pluginResult.message;
var retVal = [];
var retVal = [];
for (i=0; i<entries.length; i++) {
retVal.push(window.localFileSystem._createEntry(entries[i]));
}
pluginResult.message = retVal;
return pluginResult;
return pluginResult;
}
LocalFileSystem.prototype._createEntry = function(castMe) {
@@ -740,8 +747,8 @@ LocalFileSystem.prototype._createEntry = function(castMe) {
entry.isFile = castMe.isFile;
entry.name = castMe.name;
entry.fullPath = castMe.fullPath;
return entry;
return entry;
}
LocalFileSystem.prototype._castDate = function(pluginResult) {
@@ -756,15 +763,16 @@ LocalFileSystem.prototype._castDate = function(pluginResult) {
file.name = pluginResult.message.name;
file.fullPath = pluginResult.message.fullPath;
file.lastModifedDate = new Date(pluginResult.message.lastModifiedDate);
pluginResult.message = file;
pluginResult.message = file;
}
return pluginResult;
return pluginResult;
}
/**
* Information about the state of the file or directory
*
*
* @constructor
* {Date} modificationTime (readonly)
*/
Metadata = function() {
@@ -773,8 +781,9 @@ Metadata = function() {
/**
* Supplies arguments to methods that lookup or create files and directories
*
* @param {boolean} create file or directory if it doesn't exist
*
* @constructor
* @param {boolean} create file or directory if it doesn't exist
* @param {boolean} exclusive if true the command will fail if the file or directory exists
*/
Flags = function(create, exclusive) {
@@ -784,7 +793,8 @@ Flags = function(create, exclusive) {
/**
* An interface representing a file system
*
*
* @constructor
* {DOMString} name the unique name of the file system (readonly)
* {DirectoryEntry} root directory of the file system (readonly)
*/
@@ -795,7 +805,8 @@ FileSystem = function() {
/**
* An interface representing a directory on the file system.
*
*
* @constructor
* {boolean} isFile always false (readonly)
* {boolean} isDirectory always true (readonly)
* {DOMString} name of the directory, excluding the path leading to it (readonly)
@@ -812,7 +823,7 @@ DirectoryEntry = function() {
/**
* Copies a directory to a new location
*
*
* @param {DirectoryEntry} parent the directory to which to copy the entry
* @param {DOMString} newName the new name of the entry, defaults to the current name
* @param {Function} successCallback is called with the new entry
@@ -824,7 +835,7 @@ DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, err
/**
* Looks up the metadata of the entry
*
*
* @param {Function} successCallback is called with a Metadata object
* @param {Function} errorCallback is called with a FileError
*/
@@ -834,7 +845,7 @@ DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback)
/**
* Gets the parent of the entry
*
*
* @param {Function} successCallback is called with a parent entry
* @param {Function} errorCallback is called with a FileError
*/
@@ -844,7 +855,7 @@ DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
/**
* Moves a directory to a new location
*
*
* @param {DirectoryEntry} parent the directory to which to move the entry
* @param {DOMString} newName the new name of the entry, defaults to the current name
* @param {Function} successCallback is called with the new entry
@@ -856,7 +867,7 @@ DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, err
/**
* Removes the entry
*
*
* @param {Function} successCallback is called with no parameters
* @param {Function} errorCallback is called with a FileError
*/
@@ -866,7 +877,7 @@ DirectoryEntry.prototype.remove = function(successCallback, errorCallback) {
/**
* Returns a URI that can be used to identify this entry.
*
*
* @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
* @return uri
*/
@@ -883,7 +894,7 @@ DirectoryEntry.prototype.createReader = function(successCallback, errorCallback)
/**
* Creates or looks up a directory
*
*
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
* @param {Flags} options to create or excluively create the directory
* @param {Function} successCallback is called with the new entry
@@ -895,7 +906,7 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
/**
* Creates or looks up a file
*
*
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
* @param {Flags} options to create or excluively create the file
* @param {Function} successCallback is called with the new entry
@@ -907,7 +918,7 @@ DirectoryEntry.prototype.getFile = function(path, options, successCallback, erro
/**
* Deletes a directory and all of it's contents
*
*
* @param {Function} successCallback is called with no parameters
* @param {Function} errorCallback is called with a FileError
*/
@@ -917,24 +928,26 @@ DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCall
/**
* An interface that lists the files and directories in a directory.
* @constructor
*/
DirectoryReader = function(fullPath){
this.fullPath = fullPath || null;
function DirectoryReader(fullPath){
this.fullPath = fullPath || null;
};
/**
* Returns a list of entries from a directory.
*
*
* @param {Function} successCallback is called with a list of entries
* @param {Function} errorCallback is called with a FileError
*/
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
PhoneGap.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
}
/**
* An interface representing a directory on the file system.
*
*
* @constructor
* {boolean} isFile always true (readonly)
* {boolean} isDirectory always false (readonly)
* {DOMString} name of the file, excluding the path leading to it (readonly)
@@ -951,7 +964,7 @@ FileEntry = function() {
/**
* Copies a file to a new location
*
*
* @param {DirectoryEntry} parent the directory to which to copy the entry
* @param {DOMString} newName the new name of the entry, defaults to the current name
* @param {Function} successCallback is called with the new entry
@@ -963,7 +976,7 @@ FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCal
/**
* Looks up the metadata of the entry
*
*
* @param {Function} successCallback is called with a Metadata object
* @param {Function} errorCallback is called with a FileError
*/
@@ -973,7 +986,7 @@ FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
/**
* Gets the parent of the entry
*
*
* @param {Function} successCallback is called with a parent entry
* @param {Function} errorCallback is called with a FileError
*/
@@ -983,7 +996,7 @@ FileEntry.prototype.getParent = function(successCallback, errorCallback) {
/**
* Moves a directory to a new location
*
*
* @param {DirectoryEntry} parent the directory to which to move the entry
* @param {DOMString} newName the new name of the entry, defaults to the current name
* @param {Function} successCallback is called with the new entry
@@ -995,7 +1008,7 @@ FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCal
/**
* Removes the entry
*
*
* @param {Function} successCallback is called with no parameters
* @param {Function} errorCallback is called with a FileError
*/
@@ -1005,7 +1018,7 @@ FileEntry.prototype.remove = function(successCallback, errorCallback) {
/**
* Returns a URI that can be used to identify this entry.
*
*
* @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
* @return uri
*/
@@ -1015,7 +1028,7 @@ FileEntry.prototype.toURI = function(mimeType) {
/**
* Creates a new FileWriter associated with the file that this FileEntry represents.
*
*
* @param {Function} successCallback is called with the new FileWriter
* @param {Function} errorCallback is called with a FileError
*/
@@ -1029,7 +1042,7 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
});
}
}
if (typeof successCallback == "function") {
successCallback(writer);
}
@@ -1037,7 +1050,7 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
/**
* Returns a File that represents the current state of the file that this FileEntry represents.
*
*
* @param {Function} successCallback is called with the new File object
* @param {Function} errorCallback is called with a FileError
*/

View File

@@ -1,7 +1,7 @@
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
*
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010, IBM Corporation
*/
@@ -11,11 +11,13 @@ PhoneGap.addResource("filetransfer");
/**
* FileTransfer uploads a file to a remote server.
* @constructor
*/
FileTransfer = function() {};
/**
* FileUploadResult
* @constructor
*/
FileUploadResult = function() {
this.bytesSent = 0;
@@ -25,6 +27,7 @@ FileUploadResult = function() {
/**
* FileTransferError
* @constructor
*/
FileTransferError = function() {
this.code = null;
@@ -35,13 +38,13 @@ FileTransferError.INVALID_URL_ERR = 2;
FileTransferError.CONNECTION_ERR = 3;
/**
* Given an absolute file path, uploads a file on the device to a remote server
* Given an absolute file path, uploads a file on the device to a remote server
* using a multipart HTTP request.
* @param filePath {String} Full path of the file on the device
* @param server {String} URL of the server to receive the file
* @param successCallback (Function} Callback to be invoked when upload has completed
* @param errorCallback {Function} Callback to be invoked upon error
* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
*/
FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, debug) {
@@ -61,12 +64,13 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
params = {};
}
}
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug]);
};
/**
* Options to customize the HTTP request used to upload files.
* @constructor
* @param fileKey {String} Name of file request parameter.
* @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
* @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.

View File

@@ -25,6 +25,7 @@ Geolocation = function() {
/**
* Position error object
*
* @constructor
* @param code
* @param message
*/

View File

@@ -18,6 +18,7 @@ PhoneGap.mediaObjects = {};
/**
* Object that receives native callbacks.
* PRIVATE
* @constructor
*/
PhoneGap.Media = function() {};
@@ -66,6 +67,7 @@ PhoneGap.Media.onStatus = function(id, msg, value) {
/**
* This class provides access to the device media, interfaces to both sound and video
*
* @constructor
* @param src The file name or url to play
* @param successCallback The callback to be called when the file is done playing or recording.
* successCallback() - OPTIONAL
@@ -174,8 +176,6 @@ Media.prototype.getDuration = function() {
/**
* Get position of audio.
*
* @return
*/
Media.prototype.getCurrentPosition = function(success, fail) {
PhoneGap.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);

View File

@@ -11,6 +11,7 @@ PhoneGap.addResource("notification");
/**
* This class provides access to notifications on the device.
* @constructor
*/
Notification = function() {
};

View File

@@ -1,7 +1,7 @@
/*
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
*
* Copyright (c) 2005-2010, Nitobi Software Inc.
* Copyright (c) 2010-2011, IBM Corporation
*/
@@ -76,6 +76,7 @@ PhoneGap.addResource = function(name) {
/**
* Custom pub-sub channel that can have functions subscribed to it
* @constructor
*/
PhoneGap.Channel = function (type)
{
@@ -87,7 +88,7 @@ PhoneGap.Channel = function (type)
};
/**
* Subscribes the given function to the channel. Any time that
* Subscribes the given function to the channel. Any time that
* Channel.fire is called so too will the function.
* Optionally specify an execution context for the function
* and a guid that can be used to stop subscribing to the channel.
@@ -127,7 +128,7 @@ PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
return g;
};
/**
/**
* Unsubscribes the function with the given guid from the channel.
*/
PhoneGap.Channel.prototype.unsubscribe = function(g) {
@@ -136,7 +137,7 @@ PhoneGap.Channel.prototype.unsubscribe = function(g) {
delete this.handlers[g];
};
/**
/**
* Calls all functions subscribed to this channel.
*/
PhoneGap.Channel.prototype.fire = function(e) {
@@ -229,7 +230,7 @@ PhoneGap.addPlugin = function(name, obj) {
};
/**
* onDOMContentLoaded channel is fired when the DOM content
* onDOMContentLoaded channel is fired when the DOM content
* of the page has been parsed.
*/
PhoneGap.onDOMContentLoaded = new PhoneGap.Channel('onDOMContentLoaded');
@@ -277,7 +278,7 @@ PhoneGap.onPause = new PhoneGap.Channel('onPause');
/**
* onDestroy channel is fired when the PhoneGap native code
* is destroyed. It is used internally.
* is destroyed. It is used internally.
* Window.onunload should be used by the user.
*/
PhoneGap.onDestroy = new PhoneGap.Channel('onDestroy');
@@ -287,7 +288,7 @@ PhoneGap.onDestroy.subscribeOnce(function() {
PhoneGap.shuttingDown = false;
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
// to signify that the native code is ready. It is a global since
// it may be called before any PhoneGap JS is ready.
if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
@@ -323,7 +324,7 @@ PhoneGap.waitForInitialization = function(feature) {
* Indicate that initialization code has completed and the feature is ready to be used.
*
* @param feature {String} The unique feature name
*/
*/
PhoneGap.initializationComplete = function(feature) {
var channel = PhoneGap.deviceReadyChannelsMap[feature];
if (channel) {
@@ -361,7 +362,7 @@ PhoneGap.Channel.join(function() {
// Fire onDeviceReady event once all constructors have run and PhoneGap info has been
// received from native side, and any user defined initialization channels.
PhoneGap.Channel.join(function() {
// Turn off app loading dialog
navigator.notification.activityStop();
@@ -392,18 +393,18 @@ document.addEventListener = function(evt, handler, capture) {
}
} else if (e === 'pause') {
PhoneGap.onPause.subscribe(handler);
}
}
else {
// If subscribing to Android backbutton
if (e === 'backbutton') {
PhoneGap.exec(null, null, "App", "overrideBackbutton", [true]);
}
}
PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
}
};
// Intercept calls to document.removeEventListener and watch for events that
// Intercept calls to document.removeEventListener and watch for events that
// are generated by PhoneGap native code
PhoneGap.m_document_removeEventListener = document.removeEventListener;
@@ -413,7 +414,7 @@ document.removeEventListener = function(evt, handler, capture) {
// If unsubscribing to Android backbutton
if (e === 'backbutton') {
PhoneGap.exec(null, null, "App", "overrideBackbutton", [false]);
}
}
PhoneGap.m_document_removeEventListener.call(document, evt, handler, capture);
};
@@ -432,7 +433,7 @@ PhoneGap.fireEvent = function(type) {
* The restriction on ours is that it must be an array of simple types.
*
* @param args
* @return
* @return {String}
*/
PhoneGap.stringify = function(args) {
if (typeof JSON === "undefined") {
@@ -464,7 +465,7 @@ PhoneGap.stringify = function(args) {
// don't copy the functions
s = s + '""';
} else if (args[i][name] instanceof Object) {
s = s + this.stringify(args[i][name]);
s = s + PhoneGap.stringify(args[i][name]);
} else {
s = s + '"' + args[i][name] + '"';
}
@@ -490,7 +491,7 @@ PhoneGap.stringify = function(args) {
* Does a deep clone of the object.
*
* @param obj
* @return
* @return {Object}
*/
PhoneGap.clone = function(obj) {
var i, retVal;
@@ -544,7 +545,7 @@ PhoneGap.callbackStatus = {
/**
* Execute a PhoneGap command. It is up to the native side whether this action is synch or async.
* Execute a PhoneGap command. It is up to the native side whether this action is synch or async.
* The native side can return:
* Synchronous: PluginResult object as a JSON string
* Asynchrounous: Empty string ""
@@ -555,7 +556,7 @@ PhoneGap.callbackStatus = {
* @param {Function} fail The fail callback
* @param {String} service The name of the service to use
* @param {String} action Action to be run in PhoneGap
* @param {String[]} [args] Zero or more arguments to pass to the method
* @param {Array.<String>} [args] Zero or more arguments to pass to the method
*/
PhoneGap.exec = function(success, fail, service, action, args) {
try {
@@ -563,13 +564,13 @@ PhoneGap.exec = function(success, fail, service, action, args) {
if (success || fail) {
PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
}
var r = prompt(this.stringify(args), "gap:"+this.stringify([service, action, callbackId, true]));
var r = prompt(PhoneGap.stringify(args), "gap:"+PhoneGap.stringify([service, action, callbackId, true]));
// If a result was returned
if (r.length > 0) {
eval("var v="+r+";");
// If status is OK, then return value back to caller
if (v.status === PhoneGap.callbackStatus.OK) {
@@ -592,7 +593,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
// If no result
else if (v.status === PhoneGap.callbackStatus.NO_RESULT) {
// Clear callback if not expecting any more results
if (!v.keepCallback) {
delete PhoneGap.callbacks[callbackId];
@@ -645,7 +646,7 @@ PhoneGap.callbackSuccess = function(callbackId, args) {
console.log("Error in success callback: "+callbackId+" = "+e);
}
}
// Clear callback if not expecting any more results
if (!args.keepCallback) {
delete PhoneGap.callbacks[callbackId];
@@ -669,7 +670,7 @@ PhoneGap.callbackError = function(callbackId, args) {
catch (e) {
console.log("Error in error callback: "+callbackId+" = "+e);
}
// Clear callback if not expecting any more results
if (!args.keepCallback) {
delete PhoneGap.callbacks[callbackId];
@@ -735,7 +736,7 @@ PhoneGap.JSCallbackToken = null;
/**
* This is only for Android.
*
* Internal function that uses XHR to call into PhoneGap Java code and retrieve
* Internal function that uses XHR to call into PhoneGap Java code and retrieve
* any JavaScript code that needs to be run. This is used for callbacks from
* Java to JavaScript.
*/
@@ -757,7 +758,7 @@ PhoneGap.JSCallback = function() {
// Callback function when XMLHttpRequest is ready
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState === 4){
// Exit if shutting down app
if (PhoneGap.shuttingDown) {
return;
@@ -836,7 +837,7 @@ PhoneGap.UsePolling = false; // T=use polling, F=use XHR
/**
* This is only for Android.
*
* Internal function that uses polling to call into PhoneGap Java code and retrieve
* Internal function that uses polling to call into PhoneGap Java code and retrieve
* any JavaScript code that needs to be run. This is used for callbacks from
* Java to JavaScript.
*/
@@ -874,7 +875,7 @@ PhoneGap.JSCallbackPolling = function() {
/**
* Create a UUID
*
* @return
* @return {String}
*/
PhoneGap.createUUID = function() {
return PhoneGap.UUIDcreatePart(4) + '-' +
@@ -916,7 +917,7 @@ PhoneGap.close = function(context, func, params) {
* @param {Function} successCallback The callback to call when the file has been loaded.
*/
PhoneGap.includeJavascript = function(jsfile, successCallback) {
var id = document.getElementsByTagName("head")[0];
var id = document.getElementsByTagName("head")[0];
var el = document.createElement('script');
el.type = 'text/javascript';
if (typeof successCallback === 'function') {

View File

@@ -25,7 +25,8 @@ Position = function(coords, timestamp) {
this.timestamp = (timestamp !== 'undefined') ? timestamp : new Date().getTime();
};
Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
/** @constructor */
function Coordinates(lat, lng, alt, acc, head, vel, altacc) {
/**
* The latitude of the position.
*/
@@ -53,8 +54,8 @@ Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
/**
* The altitude accuracy of the position.
*/
this.altitudeAccuracy = (altacc !== 'undefined') ? altacc : null;
};
this.altitudeAccuracy = (altacc !== 'undefined') ? altacc : null;
}
/**
* This class specifies the options for requesting position data.

View File

@@ -18,6 +18,7 @@ PhoneGap.addResource("storage");
/**
* Storage object that is called by native code when performing queries.
* PRIVATE METHOD
* @constructor
*/
var DroidDB = function() {
this.queryQueue = {};
@@ -105,6 +106,7 @@ DroidDB.prototype.fail = function(reason, id) {
/**
* Transaction object
* PRIVATE METHOD
* @constructor
*/
var DroidDB_Tx = function() {
@@ -165,7 +167,7 @@ DroidDB_Tx.prototype.queryComplete = function(id) {
var i;
for (i in this.queryList) {
if (this.queryList.hasOwnProperty(i)) {
count++;
count++;
}
}
if (count === 0) {
@@ -205,6 +207,7 @@ DroidDB_Tx.prototype.queryFailed = function(id, reason) {
* SQL query object
* PRIVATE METHOD
*
* @constructor
* @param tx The transaction object that this query belongs to
*/
var DroidDB_Query = function(tx) {
@@ -260,6 +263,7 @@ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCa
/**
* SQL result set that is returned to user.
* PRIVATE METHOD
* @constructor
*/
DroidDB_Result = function() {
this.rows = new DroidDB_Rows();
@@ -268,6 +272,7 @@ DroidDB_Result = function() {
/**
* SQL result set object
* PRIVATE METHOD
* @constructor
*/
DroidDB_Rows = function() {
this.resultSet = []; // results array
@@ -301,14 +306,17 @@ DroidDB_openDatabase = function(name, version, display_name, size) {
/**
* For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
* TODO: Do similar for sessionStorage.
* For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
* TODO: Do similar for sessionStorage.
*/
/**
* @constructor
*/
var CupcakeLocalStorage = function() {
try {
this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
var storage = {};
this.length = 0;
function setLength (length) {
@@ -326,8 +334,8 @@ var CupcakeLocalStorage = function() {
setLength(result.rows.length);
PhoneGap.initializationComplete("cupcakeStorage");
});
},
},
function (err) {
alert(err.message);
}
@@ -344,7 +352,7 @@ var CupcakeLocalStorage = function() {
}
);
};
this.getItem = function(key) {
this.getItem = function(key) {
return storage[key];
};
this.removeItem = function(key) {