You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/08/24 02:50:04 UTC
[3/4] Synching javascript files
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/724ee4d7/javascript/cordova.playbook.js
----------------------------------------------------------------------
diff --git a/javascript/cordova.playbook.js b/javascript/cordova.playbook.js
index 5cbb958..f9455dc 100644
--- a/javascript/cordova.playbook.js
+++ b/javascript/cordova.playbook.js
@@ -1,6 +1,6 @@
-// commit 03f21d410bfa7f26c0cbd8ebb5682fc88cf59fca
+// commit b58d6387cacaae999dc83778f794cf5900ae8dfe
-// File generated at :: Wed Aug 15 2012 15:31:57 GMT-0700 (PDT)
+// File generated at :: Thu Aug 23 2012 17:49:07 GMT-0700 (PDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -29,6 +29,10 @@ var require,
(function () {
var modules = {};
+ // Stack of moduleIds currently being built.
+ var requireStack = [];
+ // Map of module ID -> index into requireStack of modules currently being built.
+ var inProgressModules = {};
function build(module) {
var factory = module.factory;
@@ -41,8 +45,21 @@ var require,
require = function (id) {
if (!modules[id]) {
throw "module " + id + " not found";
+ } else if (id in inProgressModules) {
+ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
+ throw "Cycle in require graph: " + cycle;
}
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
+ if (modules[id].factory) {
+ try {
+ inProgressModules[id] = requireStack.length;
+ requireStack.push(id);
+ return build(modules[id]);
+ } finally {
+ delete inProgressModules[id];
+ requireStack.pop();
+ }
+ }
+ return modules[id].exports;
};
define = function (id, factory) {
@@ -67,6 +84,7 @@ if (typeof module === "object" && typeof require === "function") {
module.exports.require = require;
module.exports.define = define;
}
+
// file: lib/cordova.js
define("cordova", function(require, exports, module) {
var channel = require('cordova/channel');
@@ -207,10 +225,6 @@ var cordova = {
window.dispatchEvent(evt);
}
},
- // TODO: this is Android only; think about how to do this better
- shuttingDown:false,
- UsePolling:false,
- // END TODO
// TODO: iOS only
// This queue holds the currently executing command and all pending
@@ -937,40 +951,40 @@ module.exports = function(success, fail, service, action, args) {
});
-// file: lib/playbook/platform.js
+// file: lib/webworks/air/platform.js
define("cordova/platform", function(require, exports, module) {
module.exports = {
id: "playbook",
initialize:function() {},
objects: {
DirectoryReader:{
- path: 'cordova/plugin/playbook/DirectoryReader'
+ path: 'cordova/plugin/air/DirectoryReader'
},
File:{
- path: 'cordova/plugin/playbook/File'
+ path: 'cordova/plugin/air/File'
},
FileReader:{
- path: 'cordova/plugin/playbook/FileReader'
+ path: 'cordova/plugin/air/FileReader'
},
FileWriter:{
- path: 'cordova/plugin/playbook/FileWriter'
+ path: 'cordova/plugin/air/FileWriter'
},
requestFileSystem:{
- path: 'cordova/plugin/playbook/requestFileSystem'
+ path: 'cordova/plugin/air/requestFileSystem'
},
resolveLocalFileSystemURI:{
- path: 'cordova/plugin/playbook/resolveLocalFileSystemURI'
+ path: 'cordova/plugin/air/resolveLocalFileSystemURI'
}
},
merges: {
DirectoryEntry: {
- path: 'cordova/plugin/playbook/DirectoryEntry'
+ path: 'cordova/plugin/air/DirectoryEntry'
},
Entry: {
- path: 'cordova/plugin/playbook/Entry'
+ path: 'cordova/plugin/air/Entry'
},
FileEntry:{
- path: 'cordova/plugin/playbook/FileEntry'
+ path: 'cordova/plugin/air/FileEntry'
}
}
};
@@ -2951,7 +2965,6 @@ Media.prototype.stop = function() {
var me = this;
exec(function() {
me._position = 0;
- me.successCallback();
}, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
};
@@ -3114,28 +3127,6 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
}
};
-// TODO: can we axe this?
-/**
- * Casts a PluginResult message property (array of objects) to an array of MediaFile objects
- * (used in Objective-C and Android)
- *
- * @param {PluginResult} pluginResult
- */
-MediaFile.cast = function(pluginResult) {
- var mediaFiles = [];
- for (var i=0; i<pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
-};
-
module.exports = MediaFile;
});
@@ -3424,1389 +3415,617 @@ module.exports = accelerometer;
});
-// file: lib/common/plugin/battery.js
-define("cordova/plugin/battery", function(require, exports, module) {
-/**
- * This class contains information about the current battery status.
- * @constructor
- */
-var cordova = require('cordova'),
- exec = require('cordova/exec');
+// file: lib/webworks/air/plugin/air/DirectoryEntry.js
+define("cordova/plugin/air/DirectoryEntry", function(require, exports, module) {
+var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+ DirectoryReader = require('cordova/plugin/air/DirectoryReader'),
+ FileEntry = require('cordova/plugin/FileEntry'),
+ FileError = require('cordova/plugin/FileError');
-function handlers() {
- return battery.channels.batterystatus.numHandlers +
- battery.channels.batterylow.numHandlers +
- battery.channels.batterycritical.numHandlers;
-}
+var validFileRe = new RegExp('^[a-zA-Z][0-9a-zA-Z._ ]*$');
-var Battery = function() {
- this._level = null;
- this._isPlugged = null;
- // Create new event handlers on the window (returns a channel instance)
- var subscriptionEvents = {
- onSubscribe:this.onSubscribe,
- onUnsubscribe:this.onUnsubscribe
- };
- this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
- batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
- batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
- };
-};
-/**
- * Event handlers for when callbacks get registered for the battery.
- * Keep track of how many handlers we have so we can start and stop the native battery listener
- * appropriately (and hopefully save on battery life!).
- */
-Battery.prototype.onSubscribe = function() {
- var me = battery;
- // If we just registered the first handler, make sure native listener is started.
- if (handlers() === 1) {
- exec(me._status, me._error, "Battery", "start", []);
- }
-};
+module.exports = {
+ createReader : function() {
+ return new DirectoryReader(this.fullPath);
+ },
+ /**
+ * Creates or looks up a directory; override for BlackBerry.
+ *
+ * @param path
+ * {DOMString} either a relative or absolute path from this
+ * directory in which to look up or create a directory
+ * @param options
+ * {Flags} options to create or exclusively create the directory
+ * @param successCallback
+ * {Function} called with the new DirectoryEntry
+ * @param errorCallback
+ * {Function} called with a FileError
+ */
+ getDirectory : function(path, options, successCallback, errorCallback) {
+ // create directory if it doesn't exist
+ var create = (options && options.create === true) ? true : false,
+ // if true, causes failure if create is true and path already exists
+ exclusive = (options && options.exclusive === true) ? true : false,
+ // directory exists
+ exists,
+ // create a new DirectoryEntry object and invoke success callback
+ createEntry = function() {
+ var path_parts = path.split('/'),
+ name = path_parts[path_parts.length - 1],
+ dirEntry = new DirectoryEntry(name, path);
-Battery.prototype.onUnsubscribe = function() {
- var me = battery;
+ // invoke success callback
+ if (typeof successCallback === 'function') {
+ successCallback(dirEntry);
+ }
+ };
- // If we just unregistered the last handler, make sure native listener is stopped.
- if (handlers() === 0) {
- exec(null, null, "Battery", "stop", []);
- }
-};
+ var fail = function(error) {
+ if (typeof errorCallback === 'function') {
+ errorCallback(new FileError(error));
+ }
+ };
-/**
- * Callback for battery status
- *
- * @param {Object} info keys: level, isPlugged
- */
-Battery.prototype._status = function(info) {
- if (info) {
- var me = battery;
- var level = info.level;
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
- // Fire batterystatus event
- cordova.fireWindowEvent("batterystatus", info);
+ // invalid path
+ if(!validFileRe.exec(path)){
+ fail(FileError.ENCODING_ERR);
+ return;
+ }
- // Fire low battery event
- if (level === 20 || level === 5) {
- if (level === 20) {
- cordova.fireWindowEvent("batterylow", info);
- }
- else {
- cordova.fireWindowEvent("batterycritical", info);
+ // determine if path is relative or absolute
+ if (!path) {
+ fail(FileError.ENCODING_ERR);
+ 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
+ exists = blackberry.io.dir.exists(path);
+ } catch (e) {
+ // invalid path
+ // TODO this will not work on playbook - need to think how to find invalid urls
+ fail(FileError.ENCODING_ERR);
+ return;
+ }
+
+
+ // path is a directory
+ if (exists) {
+ if (create && exclusive) {
+ // can't guarantee exclusivity
+ fail(FileError.PATH_EXISTS_ERR);
+ } else {
+ // create entry for existing directory
+ createEntry();
+ }
+ }
+ // will return true if path exists AND is a file
+ else if (blackberry.io.file.exists(path)) {
+ // the path is a file
+ fail(FileError.TYPE_MISMATCH_ERR);
+ }
+ // path does not exist, create it
+ else if (create) {
+ try {
+ // directory path must have trailing slash
+ var dirPath = path;
+ if (dirPath.substr(-1) !== '/') {
+ dirPath += '/';
}
+ console.log('creating dir path at: ' + dirPath);
+ blackberry.io.dir.createNewDir(dirPath);
+ createEntry();
+ } catch (eone) {
+ // unable to create directory
+ fail(FileError.NOT_FOUND_ERR);
}
}
- me._level = level;
- me._isPlugged = info.isPlugged;
- }
-};
+ // path does not exist, don't create
+ else {
+ // directory doesn't exist
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ },
-/**
- * Error callback for battery start
- */
-Battery.prototype._error = function(e) {
- console.log("Error initializing Battery: " + e);
-};
+ /**
+ * 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
+ * @param options {Flags}
+ * options to create or exclusively create the file
+ * @param successCallback {Function}
+ * called with the new FileEntry object
+ * @param errorCallback {Function}
+ * called with a FileError object if error occurs
+ */
+ getFile : function(path, options, successCallback, errorCallback) {
+ // create file if it doesn't exist
+ var create = (options && options.create === true) ? true : false,
+ // if true, causes failure if create is true and path already exists
+ exclusive = (options && options.exclusive === true) ? true : false,
+ // file exists
+ exists,
+ // create a new FileEntry object and invoke success callback
+ createEntry = function() {
+ var path_parts = path.split('/'),
+ name = path_parts[path_parts.length - 1],
+ fileEntry = new FileEntry(name, path);
-var battery = new Battery();
+ // invoke success callback
+ if (typeof successCallback === 'function') {
+ successCallback(fileEntry);
+ }
+ };
-module.exports = battery;
-});
+ var fail = function(error) {
+ if (typeof errorCallback === 'function') {
+ errorCallback(new FileError(error));
+ }
+ };
-// file: lib/common/plugin/capture.js
-define("cordova/plugin/capture", function(require, exports, module) {
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
+ // invalid path
+ if(!validFileRe.exec(path)){
+ fail(FileError.ENCODING_ERR);
+ return;
+ }
+ // determine if path is relative or absolute
+ if (!path) {
+ fail(FileError.ENCODING_ERR);
+ 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;
+ }
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-function _capture(type, successCallback, errorCallback, options) {
- var win = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult[i].name;
- mediaFile.fullPath = pluginResult[i].fullPath;
- mediaFile.type = pluginResult[i].type;
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
- mediaFile.size = pluginResult[i].size;
- mediaFiles.push(mediaFile);
+ // determine if file exists
+ try {
+ // will return true if path exists AND is a file
+ exists = blackberry.io.file.exists(path);
+ }
+ catch (e) {
+ // invalid path
+ fail(FileError.ENCODING_ERR);
+ return;
}
- successCallback(mediaFiles);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-module.exports = new Capture();
-
-});
-// file: lib/common/plugin/compass.js
-define("cordova/plugin/compass", function(require, exports, module) {
-var exec = require('cordova/exec'),
- utils = require('cordova/utils'),
- CompassHeading = require('cordova/plugin/CompassHeading'),
- CompassError = require('cordova/plugin/CompassError'),
- timers = {},
- compass = {
- /**
- * Asynchronously acquires the current heading.
- * @param {Function} successCallback The function to call when the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {CompassOptions} options The options for getting the heading data (not used).
- */
- getCurrentHeading:function(successCallback, errorCallback, options) {
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return;
+ // path is a file
+ if (exists) {
+ if (create && exclusive) {
+ // can't guarantee exclusivity
+ fail(FileError.PATH_EXISTS_ERR);
}
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- return;
+ else {
+ // create entry for existing file
+ createEntry();
}
+ }
+ // will return true if path exists AND is a directory
+ else if (blackberry.io.dir.exists(path)) {
+ // the path is a directory
+ fail(FileError.TYPE_MISMATCH_ERR);
+ }
+ // path does not exist, create it
+ else if (create) {
+ // create empty file
+ var emptyBlob = blackberry.utils.stringToBlob('');
+ blackberry.io.file.saveFile(path,emptyBlob);
+ createEntry();
+ }
+ // path does not exist, don't create
+ else {
+ // file doesn't exist
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ },
- var win = function(result) {
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
- successCallback(ch);
- };
- var fail = function(code) {
- var ce = new CompassError(code);
- errorCallback(ce);
- };
-
- // Get heading
- exec(win, fail, "Compass", "getHeading", [options]);
- },
-
- /**
- * Asynchronously acquires the heading repeatedly at a given interval.
- * @param {Function} successCallback The function to call each time the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {HeadingOptions} options The options for getting the heading data
- * such as timeout and the frequency of the watch. For iOS, filter parameter
- * specifies to watch via a distance filter rather than time.
- */
- watchHeading:function(successCallback, errorCallback, options) {
- // Default interval (100 msec)
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
- var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return;
- }
+ /**
+ * Delete a directory and all of it's contents.
+ *
+ * @param successCallback {Function} called with no parameters
+ * @param errorCallback {Function} called with a FileError
+ */
+ removeRecursively : function(successCallback, errorCallback) {
+ // we're removing THIS directory
+ var path = this.fullPath;
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- return;
+ var fail = function(error) {
+ if (typeof errorCallback === 'function') {
+ errorCallback(new FileError(error));
}
+ };
- var id = utils.createUUID();
- if (filter > 0) {
- // is an iOS request for watch by filter, no timer needed
- timers[id] = "iOS";
- compass.getCurrentHeading(successCallback, errorCallback, options);
- } else {
- // Start watch timer to get headings
- timers[id] = window.setInterval(function() {
- compass.getCurrentHeading(successCallback, errorCallback);
- }, frequency);
+ // attempt to delete directory
+ if (blackberry.io.dir.exists(path)) {
+ // it is an error to attempt to remove the file system root
+ //exec(null, null, "File", "isFileSystemRoot", [ path ]) === true
+ if (false) {
+ fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
}
-
- return id;
- },
-
- /**
- * Clears the specified heading watch.
- * @param {String} watchId The ID of the watch returned from #watchHeading.
- */
- clearWatch:function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- if (timers[id] != "iOS") {
- clearInterval(timers[id]);
- } else {
- // is iOS watch by filter so call into device to stop
- exec(null, null, "Compass", "stopHeading", []);
+ else {
+ try {
+ // delete the directory, setting recursive flag to true
+ blackberry.io.dir.deleteDirectory(path, true);
+ if (typeof successCallback === "function") {
+ successCallback();
+ }
+ } catch (e) {
+ // permissions don't allow deletion
+ console.log(e);
+ fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
}
- delete timers[id];
}
}
- };
-
-module.exports = compass;
-});
-
-// file: lib/common/plugin/console-via-logger.js
-define("cordova/plugin/console-via-logger", function(require, exports, module) {
-//------------------------------------------------------------------------------
-
-var logger = require("cordova/plugin/logger");
-var utils = require("cordova/utils");
-
-//------------------------------------------------------------------------------
-// object that we're exporting
-//------------------------------------------------------------------------------
-var console = module.exports;
-
-//------------------------------------------------------------------------------
-// copy of the original console object
-//------------------------------------------------------------------------------
-var WinConsole = window.console;
-
-//------------------------------------------------------------------------------
-// whether to use the logger
-//------------------------------------------------------------------------------
-var UseLogger = false;
-
-//------------------------------------------------------------------------------
-// Timers
-//------------------------------------------------------------------------------
-var Timers = {};
-
-//------------------------------------------------------------------------------
-// used for unimplemented methods
-//------------------------------------------------------------------------------
-function noop() {}
-
-//------------------------------------------------------------------------------
-// used for unimplemented methods
-//------------------------------------------------------------------------------
-console.useLogger = function (value) {
- if (arguments.length) UseLogger = !!value;
-
- if (UseLogger) {
- if (logger.useConsole()) {
- throw new Error("console and logger are too intertwingly");
- }
- }
-
- return UseLogger;
-};
-
-//------------------------------------------------------------------------------
-console.log = function() {
- if (logger.useConsole()) return;
- logger.log.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.error = function() {
- if (logger.useConsole()) return;
- logger.error.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.warn = function() {
- if (logger.useConsole()) return;
- logger.warn.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.info = function() {
- if (logger.useConsole()) return;
- logger.info.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.debug = function() {
- if (logger.useConsole()) return;
- logger.debug.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.assert = function(expression) {
- if (expression) return;
-
- var message = utils.vformat(arguments[1], [].slice.call(arguments, 2));
- console.log("ASSERT: " + message);
-};
-
-//------------------------------------------------------------------------------
-console.clear = function() {};
-
-//------------------------------------------------------------------------------
-console.dir = function(object) {
- console.log("%o", object);
-};
-
-//------------------------------------------------------------------------------
-console.dirxml = function(node) {
- console.log(node.innerHTML);
-};
-
-//------------------------------------------------------------------------------
-console.trace = noop;
-
-//------------------------------------------------------------------------------
-console.group = console.log;
-
-//------------------------------------------------------------------------------
-console.groupCollapsed = console.log;
-
-//------------------------------------------------------------------------------
-console.groupEnd = noop;
-
-//------------------------------------------------------------------------------
-console.time = function(name) {
- Timers[name] = new Date().valueOf();
-};
-
-//------------------------------------------------------------------------------
-console.timeEnd = function(name) {
- var timeStart = Timers[name];
- if (!timeStart) {
- console.warn("unknown timer: " + name);
- return;
- }
-
- var timeElapsed = new Date().valueOf() - timeStart;
- console.log(name + ": " + timeElapsed + "ms");
-};
-
-//------------------------------------------------------------------------------
-console.timeStamp = noop;
-
-//------------------------------------------------------------------------------
-console.profile = noop;
-
-//------------------------------------------------------------------------------
-console.profileEnd = noop;
-
-//------------------------------------------------------------------------------
-console.count = noop;
-
-//------------------------------------------------------------------------------
-console.exception = console.log;
-
-//------------------------------------------------------------------------------
-console.table = function(data, columns) {
- console.log("%o", data);
-};
-
-//------------------------------------------------------------------------------
-// return a new function that calls both functions passed as args
-//------------------------------------------------------------------------------
-function wrapperedOrigCall(orgFunc, newFunc) {
- return function() {
- var args = [].slice.call(arguments);
- try { orgFunc.apply(WinConsole, args); } catch (e) {}
- try { newFunc.apply(console, args); } catch (e) {}
- };
-}
-
-//------------------------------------------------------------------------------
-// For every function that exists in the original console object, that
-// also exists in the new console object, wrap the new console method
-// with one that calls both
-//------------------------------------------------------------------------------
-for (var key in console) {
- if (typeof WinConsole[key] == "function") {
- console[key] = wrapperedOrigCall(WinConsole[key], console[key]);
- }
-}
-
-});
-
-// file: lib/common/plugin/contacts.js
-define("cordova/plugin/contacts", function(require, exports, module) {
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils'),
- Contact = require('cordova/plugin/Contact');
-
-/**
-* Represents a group of Contacts.
-* @constructor
-*/
-var contacts = {
- /**
- * Returns an array of Contacts matching the search criteria.
- * @param fields that should be searched
- * @param successCB success callback
- * @param errorCB error callback
- * @param {ContactFindOptions} options that can be applied to contact searching
- * @return array of Contacts matching search criteria
- */
- find:function(fields, successCB, errorCB, options) {
- if (!successCB) {
- throw new TypeError("You must specify a success callback for the find command.");
- }
- if (!fields || (utils.isArray(fields) && fields.length === 0)) {
- if (typeof errorCB === "function") {
- errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- }
- } else {
- var win = function(result) {
- var cs = [];
- for (var i = 0, l = result.length; i < l; i++) {
- cs.push(contacts.create(result[i]));
- }
- successCB(cs);
- };
- exec(win, errorCB, "Contacts", "search", [fields, options]);
- }
- },
-
- /**
- * This function creates a new contact, but it does not persist the contact
- * to device storage. To persist the contact to device storage, invoke
- * contact.save().
- * @param properties an object who's properties will be examined to create a new Contact
- * @returns new Contact object
- */
- create:function(properties) {
- var i;
- var contact = new Contact();
- for (i in properties) {
- if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
- contact[i] = properties[i];
- }
- }
- return contact;
- }
-};
-
-module.exports = contacts;
-
-});
-
-// file: lib/common/plugin/device.js
-define("cordova/plugin/device", function(require, exports, module) {
-var channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.name = null;
- this.uuid = null;
- this.cordova = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribeOnce(function() {
- me.getInfo(function(info) {
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.name = info.name;
- me.uuid = info.uuid;
- me.cordova = info.cordova;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- me.available = false;
- utils.alert("[ERROR] Error initializing Cordova: " + e);
- });
- });
-}
-
-/**
- * Get device info
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Device Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Device Error: errorCallback is not a function");
- return;
- }
-
- // Get info
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
-};
-
-module.exports = new Device();
-
-});
-
-// file: lib/common/plugin/geolocation.js
-define("cordova/plugin/geolocation", function(require, exports, module) {
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- PositionError = require('cordova/plugin/PositionError'),
- Position = require('cordova/plugin/Position');
-
-var timers = {}; // list of timers in use
-
-// Returns default params, overrides if provided with values
-function parseParameters(options) {
- var opt = {
- maximumAge: 0,
- enableHighAccuracy: false,
- timeout: Infinity
- };
-
- if (options) {
- if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
- opt.maximumAge = options.maximumAge;
- }
- if (options.enableHighAccuracy !== undefined) {
- opt.enableHighAccuracy = options.enableHighAccuracy;
- }
- if (options.timeout !== undefined && !isNaN(options.timeout)) {
- if (options.timeout < 0) {
- opt.timeout = 0;
- } else {
- opt.timeout = options.timeout;
- }
- }
- }
-
- return opt;
-}
-
-// Returns a timeout failure, closed over a specified timeout value and error callback.
-function createTimeout(errorCallback, timeout) {
- var t = setTimeout(function() {
- clearTimeout(t);
- t = null;
- errorCallback({
- code:PositionError.TIMEOUT,
- message:"Position retrieval timed out."
- });
- }, timeout);
- return t;
-}
-
-var geolocation = {
- lastPosition:null, // reference to last known (cached) position returned
- /**
- * Asynchronously aquires the current position.
- *
- * @param {Function} successCallback The function to call when the position data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
- */
- getCurrentPosition:function(successCallback, errorCallback, options) {
- if (arguments.length === 0) {
- throw new Error("getCurrentPosition must be called with at least one argument.");
- }
- options = parseParameters(options);
-
- // Timer var that will fire an error callback if no position is retrieved from native
- // before the "timeout" param provided expires
- var timeoutTimer = null;
-
- var win = function(p) {
- clearTimeout(timeoutTimer);
- if (!timeoutTimer) {
- // Timeout already happened, or native fired error callback for
- // this geo request.
- // Don't continue with success callback.
- return;
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
- var fail = function(e) {
- clearTimeout(timeoutTimer);
- timeoutTimer = null;
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
- // fire the success callback with the cached position.
- if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) {
- successCallback(geolocation.lastPosition);
- // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
- } else if (options.timeout === 0) {
- fail({
- code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceed's provided PositionOptions' maximumAge parameter."
- });
- // Otherwise we have to call into native to retrieve a position.
- } else {
- if (options.timeout !== Infinity) {
- // If the timeout value was not set to Infinity (default), then
- // set up a timeout function that will fire the error callback
- // if no successful position was retrieved before timeout expired.
- timeoutTimer = createTimeout(fail, options.timeout);
- } else {
- // This is here so the check in the win function doesn't mess stuff up
- // may seem weird but this guarantees timeoutTimer is
- // always truthy before we call into native
- timeoutTimer = true;
- }
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
- }
- return timeoutTimer;
- },
- /**
- * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
- * the successCallback is called with the new location.
- *
- * @param {Function} successCallback The function to call each time the location data is available
- * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchPosition:function(successCallback, errorCallback, options) {
- if (arguments.length === 0) {
- throw new Error("watchPosition must be called with at least one argument.");
- }
- options = parseParameters(options);
-
- var id = utils.createUUID();
-
- // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
- timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
-
- var fail = function(e) {
- clearTimeout(timers[id]);
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- var win = function(p) {
- clearTimeout(timers[id]);
- if (options.timeout !== Infinity) {
- timers[id] = createTimeout(fail, options.timeout);
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
-
- exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
-
- return id;
- },
- /**
- * Clears the specified heading watch.
- *
- * @param {String} id The ID of the watch returned from #watchPosition
- */
- clearWatch:function(id) {
- if (id && timers[id] !== undefined) {
- clearTimeout(timers[id]);
- delete timers[id];
- exec(null, null, "Geolocation", "clearWatch", [id]);
- }
- }
-};
-
-module.exports = geolocation;
-
-});
-
-// file: lib/common/plugin/logger.js
-define("cordova/plugin/logger", function(require, exports, module) {
-//------------------------------------------------------------------------------
-// The logger module exports the following properties/functions:
-//
-// LOG - constant for the level LOG
-// ERROR - constant for the level ERROR
-// WARN - constant for the level WARN
-// INFO - constant for the level INFO
-// DEBUG - constant for the level DEBUG
-// logLevel() - returns current log level
-// logLevel(value) - sets and returns a new log level
-// useConsole() - returns whether logger is using console
-// useConsole(value) - sets and returns whether logger is using console
-// log(message,...) - logs a message at level LOG
-// error(message,...) - logs a message at level ERROR
-// warn(message,...) - logs a message at level WARN
-// info(message,...) - logs a message at level INFO
-// debug(message,...) - logs a message at level DEBUG
-// logLevel(level,message,...) - logs a message specified level
-//
-//------------------------------------------------------------------------------
-
-var logger = exports;
-
-var exec = require('cordova/exec');
-var utils = require('cordova/utils');
-
-var UseConsole = true;
-var Queued = [];
-var DeviceReady = false;
-var CurrentLevel;
-
-/**
- * Logging levels
- */
-
-var Levels = [
- "LOG",
- "ERROR",
- "WARN",
- "INFO",
- "DEBUG"
-];
-
-/*
- * add the logging levels to the logger object and
- * to a separate levelsMap object for testing
- */
-
-var LevelsMap = {};
-for (var i=0; i<Levels.length; i++) {
- var level = Levels[i];
- LevelsMap[level] = i;
- logger[level] = level;
-}
-
-CurrentLevel = LevelsMap.WARN;
-
-/**
- * Getter/Setter for the logging level
- *
- * Returns the current logging level.
- *
- * When a value is passed, sets the logging level to that value.
- * The values should be one of the following constants:
- * logger.LOG
- * logger.ERROR
- * logger.WARN
- * logger.INFO
- * logger.DEBUG
- *
- * The value used determines which messages get printed. The logging
- * values above are in order, and only messages logged at the logging
- * level or above will actually be displayed to the user. Eg, the
- * default level is WARN, so only messages logged with LOG, ERROR, or
- * WARN will be displayed; INFO and DEBUG messages will be ignored.
- */
-logger.level = function (value) {
- if (arguments.length) {
- if (LevelsMap[value] === null) {
- throw new Error("invalid logging level: " + value);
- }
- CurrentLevel = LevelsMap[value];
- }
-
- return Levels[CurrentLevel];
-};
-
-/**
- * Getter/Setter for the useConsole functionality
- *
- * When useConsole is true, the logger will log via the
- * browser 'console' object. Otherwise, it will use the
- * native Logger plugin.
- */
-logger.useConsole = function (value) {
- if (arguments.length) UseConsole = !!value;
-
- if (UseConsole) {
- if (typeof console == "undefined") {
- throw new Error("global console object is not defined");
- }
-
- if (typeof console.log != "function") {
- throw new Error("global console object does not have a log function");
- }
-
- if (typeof console.useLogger == "function") {
- if (console.useLogger()) {
- throw new Error("console and logger are too intertwingly");
- }
+ // it's a file, not a directory
+ else if (blackberry.io.file.exists(path)) {
+ fail(FileError.TYPE_MISMATCH_ERR);
+ }
+ // not found
+ else {
+ fail(FileError.NOT_FOUND_ERR);
}
}
-
- return UseConsole;
-};
-
-/**
- * Logs a message at the LOG level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.log = function(message) { logWithArgs("LOG", arguments); };
-
-/**
- * Logs a message at the ERROR level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.error = function(message) { logWithArgs("ERROR", arguments); };
-
-/**
- * Logs a message at the WARN level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.warn = function(message) { logWithArgs("WARN", arguments); };
-
-/**
- * Logs a message at the INFO level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.info = function(message) { logWithArgs("INFO", arguments); };
-
-/**
- * Logs a message at the DEBUG level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
-
-// log at the specified level with args
-function logWithArgs(level, args) {
- args = [level].concat([].slice.call(args));
- logger.logLevel.apply(logger, args);
-}
-
-/**
- * Logs a message at the specified level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.logLevel = function(level, message /* , ... */) {
- // format the message with the parameters
- var formatArgs = [].slice.call(arguments, 2);
- message = utils.vformat(message, formatArgs);
-
- if (LevelsMap[level] === null) {
- throw new Error("invalid logging level: " + level);
- }
-
- if (LevelsMap[level] > CurrentLevel) return;
-
- // queue the message if not yet at deviceready
- if (!DeviceReady && !UseConsole) {
- Queued.push([level, message]);
- return;
- }
-
- // if not using the console, use the native logger
- if (!UseConsole) {
- exec(null, null, "Logger", "logLevel", [level, message]);
- return;
- }
-
- // make sure console is not using logger
- if (console.__usingCordovaLogger) {
- throw new Error("console and logger are too intertwingly");
- }
-
- // log to the console
- switch (level) {
- case logger.LOG: console.log(message); break;
- case logger.ERROR: console.log("ERROR: " + message); break;
- case logger.WARN: console.log("WARN: " + message); break;
- case logger.INFO: console.log("INFO: " + message); break;
- case logger.DEBUG: console.log("DEBUG: " + message); break;
- }
-};
-
-// when deviceready fires, log queued messages
-logger.__onDeviceReady = function() {
- if (DeviceReady) return;
-
- DeviceReady = true;
-
- for (var i=0; i<Queued.length; i++) {
- var messageArgs = Queued[i];
- logger.logLevel(messageArgs[0], messageArgs[1]);
- }
-
- Queued = null;
};
-// add a deviceready event to log queued messages
-document.addEventListener("deviceready", logger.__onDeviceReady, false);
-
});
-// file: lib/playbook/plugin/manager.js
-define("cordova/plugin/manager", function(require, exports, module) {
-var cordova = require('cordova'),
- plugins = {
- 'Device' : require('cordova/plugin/playbook/device'),
- 'Battery' : require('cordova/plugin/playbook/battery'),
- 'Camera' : require('cordova/plugin/playbook/camera'),
- 'Logger' : require('cordova/plugin/playbook/logger'),
- 'Media' : require('cordova/plugin/playbook/media'),
- 'Capture' : require('cordova/plugin/playbook/capture'),
- 'Accelerometer' : require('cordova/plugin/playbook/accelerometer'),
- 'NetworkStatus' : require('cordova/plugin/playbook/network'),
- 'Notification' : require('cordova/plugin/playbook/notification'),
- 'FileTransfer' : require('cordova/plugin/playbook/FileTransfer')
- };
+// file: lib/webworks/air/plugin/air/DirectoryReader.js
+define("cordova/plugin/air/DirectoryReader", function(require, exports, module) {
+var FileError = require('cordova/plugin/FileError');
-module.exports = {
- exec: function (win, fail, clazz, action, args) {
- var result = {"status" : cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message" : "Class " + clazz + " cannot be found"};
+/**
+ * An interface that lists the files and directories in a directory.
+ */
+function DirectoryReader(path) {
+ this.path = path || null;
+}
- if (plugins[clazz]) {
- if (plugins[clazz][action]) {
- result = plugins[clazz][action](args, win, fail);
+/**
+ * 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) {
+ var win = typeof successCallback !== 'function' ? null : function(result) {
+ var retVal = [];
+ for (var i=0; i<result.length; i++) {
+ var entry = null;
+ if (result[i].isDirectory) {
+ entry = new (require('cordova/plugin/DirectoryEntry'))();
}
- else {
- result = { "status" : cordova.callbackStatus.INVALID_ACTION, "message" : "Action not found: " + action };
+ else if (result[i].isFile) {
+ entry = new (require('cordova/plugin/FileEntry'))();
}
+ entry.isDirectory = result[i].isDirectory;
+ entry.isFile = result[i].isFile;
+ entry.name = result[i].name;
+ entry.fullPath = result[i].fullPath;
+ retVal.push(entry);
}
+ successCallback(retVal);
+ };
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ errorCallback(new FileError(code));
+ };
- return result;
- },
- resume: function () {},
- pause: function () {},
- destroy: function () {}
-};
-
-});
+ var theEntries = [];
+ // Entry object is borked - unable to instantiate a new Entry object so just create one
+ var anEntry = function (isDirectory, name, fullPath) {
+ this.isDirectory = (isDirectory ? true : false);
+ this.isFile = (isDirectory ? false : true);
+ this.name = name;
+ this.fullPath = fullPath;
+ };
-// file: lib/common/plugin/network.js
-define("cordova/plugin/network", function(require, exports, module) {
-var exec = require('cordova/exec'),
- cordova = require('cordova'),
- channel = require('cordova/channel');
+ if(blackberry.io.dir.exists(this.path)){
+ var theDirectories = blackberry.io.dir.listDirectories(this.path);
+ var theFiles = blackberry.io.dir.listFiles(this.path);
-var NetworkConnection = function () {
- this.type = null;
- this._firstRun = true;
- this._timer = null;
- this.timeout = 500;
+ var theDirectoriesLength = theDirectories.length;
+ var theFilesLength = theFiles.length;
+ for(var i=0;i<theDirectoriesLength;i++){
+ theEntries.push(new anEntry(true, theDirectories[i], this.path+theDirectories[i]));
+ }
- var me = this;
+ for(var j=0;j<theFilesLength;j++){
+ theEntries.push(new anEntry(false, theFiles[j], this.path+theFiles[j]));
+ }
+ win(theEntries);
+ }else{
+ fail(FileError.NOT_FOUND_ERR);
+ }
- channel.onCordovaReady.subscribeOnce(function() {
- me.getInfo(function (info) {
- me.type = info;
- if (info === "none") {
- // set a timer if still offline at the end of timer send the offline event
- me._timer = setTimeout(function(){
- cordova.fireDocumentEvent("offline");
- me._timer = null;
- }, me.timeout);
- } else {
- // If there is a current offline event pending clear it
- if (me._timer !== null) {
- clearTimeout(me._timer);
- me._timer = null;
- }
- cordova.fireDocumentEvent("online");
- }
- // should only fire this once
- if (me._firstRun) {
- me._firstRun = false;
- channel.onCordovaConnectionReady.fire();
- }
- },
- function (e) {
- // If we can't get the network info we should still tell Cordova
- // to fire the deviceready event.
- if (me._firstRun) {
- me._firstRun = false;
- channel.onCordovaConnectionReady.fire();
- }
- console.log("Error initializing Network Connection: " + e);
- });
- });
};
-/**
- * Get connection info
- *
- * @param {Function} successCallback The function to call when the Connection data is available
- * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
- */
-NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
- // Get info
- exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
-};
+module.exports = DirectoryReader;
-module.exports = new NetworkConnection();
});
-// file: lib/common/plugin/notification.js
-define("cordova/plugin/notification", function(require, exports, module) {
-var exec = require('cordova/exec');
-
-/**
- * Provides access to notifications on the device.
- */
-
-module.exports = {
-
- /**
- * Open a native alert dialog, with a customizable title and button text.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} completeCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Alert)
- * @param {String} buttonLabel Label of the close button (default: OK)
- */
- alert: function(message, completeCallback, title, buttonLabel) {
- var _title = (title || "Alert");
- var _buttonLabel = (buttonLabel || "OK");
- exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
- },
+// file: lib/webworks/air/plugin/air/Entry.js
+define("cordova/plugin/air/Entry", function(require, exports, module) {
+var FileError = require('cordova/plugin/FileError'),
+ LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
+ Metadata = require('cordova/plugin/Metadata'),
+ resolveLocalFileSystemURI = require('cordova/plugin/air/resolveLocalFileSystemURI'),
+ DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+ FileEntry = require('cordova/plugin/FileEntry'),
+ requestFileSystem = require('cordova/plugin/air/requestFileSystem');
- /**
- * Open a native confirm dialog, with a customizable title and button text.
- * The result that the user selects is returned to the result callback.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Confirm)
- * @param {String} buttonLabels Comma separated list of the labels of the buttons (default: 'OK,Cancel')
- */
- confirm: function(message, resultCallback, title, buttonLabels) {
- var _title = (title || "Confirm");
- var _buttonLabels = (buttonLabels || "OK,Cancel");
- exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
- },
+var recursiveCopy = function(srcDirPath, dstDirPath){
+ // get all the contents (file+dir) of the dir
+ var files = blackberry.io.dir.listFiles(srcDirPath);
+ var dirs = blackberry.io.dir.listDirectories(srcDirPath);
- /**
- * Causes the device to vibrate.
- *
- * @param {Integer} mills The number of milliseconds to vibrate for.
- */
- vibrate: function(mills) {
- exec(null, null, "Notification", "vibrate", [mills]);
- },
+ for(var i=0;i<files.length;i++){
+ blackberry.io.file.copy(srcDirPath + '/' + files[i], dstDirPath + '/' + files[i]);
+ }
- /**
- * Causes the device to beep.
- * On Android, the default notification ringtone is played "count" times.
- *
- * @param {Integer} count The number of beeps.
- */
- beep: function(count) {
- exec(null, null, "Notification", "beep", [count]);
+ for(var j=0;j<dirs.length;j++){
+ if(!blackberry.io.dir.exists(dstDirPath + '/' + dirs[j])){
+ blackberry.io.dir.createNewDir(dstDirPath + '/' + dirs[j]);
+ }
+ recursiveCopy(srcDirPath + '/' + dirs[j], dstDirPath + '/' + dirs[j]);
}
};
-});
-
-// file: lib/playbook/plugin/playbook/DirectoryEntry.js
-define("cordova/plugin/playbook/DirectoryEntry", function(require, exports, module) {
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- DirectoryReader = require('cordova/plugin/playbook/DirectoryReader'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError');
var validFileRe = new RegExp('^[a-zA-Z][0-9a-zA-Z._ ]*$');
module.exports = {
- createReader : function() {
- return new DirectoryReader(this.fullPath);
- },
- /**
- * Creates or looks up a directory; override for BlackBerry.
- *
- * @param path
- * {DOMString} either a relative or absolute path from this
- * directory in which to look up or create a directory
- * @param options
- * {Flags} options to create or exclusively create the directory
- * @param successCallback
- * {Function} called with the new DirectoryEntry
- * @param errorCallback
- * {Function} called with a FileError
- */
- getDirectory : function(path, options, successCallback, errorCallback) {
- // create directory if it doesn't exist
- var create = (options && options.create === true) ? true : false,
- // if true, causes failure if create is true and path already exists
- exclusive = (options && options.exclusive === true) ? true : false,
- // directory exists
- exists,
- // create a new DirectoryEntry object and invoke success callback
- createEntry = function() {
- var path_parts = path.split('/'),
- name = path_parts[path_parts.length - 1],
- dirEntry = new DirectoryEntry(name, path);
+ getMetadata : function(successCallback, errorCallback){
+ var success = typeof successCallback !== 'function' ? null : function(lastModified) {
+ var metadata = new Metadata(lastModified);
+ successCallback(metadata);
+ };
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ errorCallback(new FileError(code));
+ };
- // invoke success callback
- if (typeof successCallback === 'function') {
- successCallback(dirEntry);
+ if(this.isFile){
+ if(blackberry.io.file.exists(this.fullPath)){
+ var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
+ success(theFileProperties.dateModified);
}
- };
+ }else{
+ console.log('Unsupported for directories');
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }
+ },
- var fail = function(error) {
+ setMetadata : function(successCallback, errorCallback , metadataObject){
+ console.log('setMetadata is unsupported for playbook');
+ },
+
+ moveTo : function(parent, newName, successCallback, errorCallback){
+ var fail = function(code) {
if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
+ errorCallback(new FileError(code));
}
};
-
- // invalid path
- if(!validFileRe.exec(path)){
- fail(FileError.ENCODING_ERR);
+ // user must specify parent Entry
+ if (!parent) {
+ fail(FileError.NOT_FOUND_ERR);
return;
}
+ // source path
+ var srcPath = this.fullPath,
+ // entry name
+ name = newName || this.name,
+ success = function(entry) {
+ if (entry) {
+ if (typeof successCallback === 'function') {
+ // create appropriate Entry object
+ var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
+ try {
+ successCallback(result);
+ }
+ catch (e) {
+ console.log('Error invoking callback: ' + e);
+ }
+ }
+ }
+ else {
+ // no Entry object returned
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ };
- // determine if path is relative or absolute
- if (!path) {
- fail(FileError.ENCODING_ERR);
- 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
- exists = blackberry.io.dir.exists(path);
- } catch (e) {
- // invalid path
- // TODO this will not work on playbook - need to think how to find invalid urls
+ // Entry object is borked
+ var theEntry = {};
+ var dstPath = parent.fullPath + '/' + name;
+
+ // invalid path
+ if(!validFileRe.exec(name)){
fail(FileError.ENCODING_ERR);
return;
}
+ if(this.isFile){
+ if(srcPath != dstPath){
+ if(blackberry.io.file.exists(dstPath)){
+ blackberry.io.file.deleteFile(dstPath);
+ blackberry.io.file.copy(srcPath,dstPath);
+ blackberry.io.file.deleteFile(srcPath);
- // path is a directory
- if (exists) {
- if (create && exclusive) {
- // can't guarantee exclusivity
- fail(FileError.PATH_EXISTS_ERR);
- } else {
- // create entry for existing directory
- createEntry();
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = false;
+ theEntry.isFile = true;
+ success(theEntry);
+ }else if(blackberry.io.dir.exists(dstPath)){
+ // destination path is a directory
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }else{
+ // make sure the directory that we are moving to actually exists
+ if(blackberry.io.dir.exists(parent.fullPath)){
+ blackberry.io.file.copy(srcPath,dstPath);
+ blackberry.io.file.deleteFile(srcPath);
+
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = false;
+ theEntry.isFile = true;
+ success(theEntry);
+ }else{
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ }
+ }else{
+ // file onto itself
+ fail(FileError.INVALID_MODIFICATION_ERR);
}
- }
- // will return true if path exists AND is a file
- else if (blackberry.io.file.exists(path)) {
- // the path is a file
- fail(FileError.TYPE_MISMATCH_ERR);
- }
- // path does not exist, create it
- else if (create) {
- try {
- // directory path must have trailing slash
- var dirPath = path;
- if (dirPath.substr(-1) !== '/') {
- dirPath += '/';
+ }else{
+ if(srcPath != dstPath){
+ if(blackberry.io.file.exists(dstPath) || srcPath == parent.fullPath){
+ // destination path is either a file path or moving into parent
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }else{
+ if(!blackberry.io.dir.exists(dstPath)){
+ blackberry.io.dir.createNewDir(dstPath);
+ recursiveCopy(srcPath,dstPath);
+ blackberry.io.dir.deleteDirectory(srcPath, true);
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = true;
+ theEntry.isFile = false;
+ success(theEntry);
+ }else{
+ var numOfEntries = 0;
+ numOfEntries += blackberry.io.dir.listDirectories(dstPath).length;
+ numOfEntries += blackberry.io.dir.listFiles(dstPath).length;
+ if(numOfEntries === 0){
+ blackberry.io.dir.createNewDir(dstPath);
+ recursiveCopy(srcPath,dstPath);
+ blackberry.io.dir.deleteDirectory(srcPath, true);
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = true;
+ theEntry.isFile = false;
+ success(theEntry);
+ }else{
+ // destination directory not empty
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }
+ }
}
- console.log('creating dir path at: ' + dirPath);
- blackberry.io.dir.createNewDir(dirPath);
- createEntry();
- } catch (eone) {
- // unable to create directory
- fail(FileError.NOT_FOUND_ERR);
+ }else{
+ // directory onto itself
+ fail(FileError.INVALID_MODIFICATION_ERR);
}
}
- // path does not exist, don't create
- else {
- // directory doesn't exist
- fail(FileError.NOT_FOUND_ERR);
- }
- },
-
- /**
- * 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
- * @param options {Flags}
- * options to create or exclusively create the file
- * @param successCallback {Function}
- * called with the new FileEntry object
- * @param errorCallback {Function}
- * called with a FileError object if error occurs
- */
- getFile : function(path, options, successCallback, errorCallback) {
- // create file if it doesn't exist
- var create = (options && options.create === true) ? true : false,
- // if true, causes failure if create is true and path already exists
- exclusive = (options && options.exclusive === true) ? true : false,
- // file exists
- exists,
- // create a new FileEntry object and invoke success callback
- createEntry = function() {
- var path_parts = path.split('/'),
- name = path_parts[path_parts.length - 1],
- fileEntry = new FileEntry(name, path);
- // invoke success callback
- if (typeof successCallback === 'function') {
- successCallback(fileEntry);
- }
- };
+ },
- var fail = function(error) {
+ copyTo : function(parent, newName, successCallback, errorCallback) {
+ var fail = function(code) {
if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
+ errorCallback(new FileError(code));
}
};
-
- // invalid path
- if(!validFileRe.exec(path)){
- fail(FileError.ENCODING_ERR);
- return;
- }
- // determine if path is relative or absolute
- if (!path) {
- fail(FileError.ENCODING_ERR);
+ // user must specify parent Entry
+ if (!parent) {
+ fail(FileError.NOT_FOUND_ERR);
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;
- }
+ // source path
+ var srcPath = this.fullPath,
+ // entry name
+ name = newName || this.name,
+ success = function(entry) {
+ if (entry) {
+ if (typeof successCallback === 'function') {
+ // create appropriate Entry object
+ var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
+ try {
+ successCallback(result);
+ }
+ catch (e) {
+ console.log('Error invoking callback: ' + e);
+ }
+ }
+ }
+ else {
+ // no Entry object returned
+ fail(FileError.NOT_FOUND_ERR);
+ }
+ };
- // determine if file exists
- try {
- // will return true if path exists AND is a file
- exists = blackberry.io.file.exists(path);
- }
- catch (e) {
- // invalid path
+ // Entry object is borked
+ var theEntry = {};
+ var dstPath = parent.fullPath + '/' + name;
+
+ // invalid path
+ if(!validFileRe.exec(name)){
fail(FileError.ENCODING_ERR);
return;
}
- // path is a file
- if (exists) {
- if (create && exclusive) {
- // can't guarantee exclusivity
- fail(FileError.PATH_EXISTS_ERR);
+ if(this.isFile){
+ if(srcPath != dstPath){
+ if(blackberry.io.file.exists(dstPath)){
+ if(blackberry.io.dir.exists(dstPath)){
+ blackberry.io.file.copy(srcPath,dstPath);
+
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = false;
+ theEntry.isFile = true;
+ success(theEntry);
+ }else{
+ // destination directory doesn't exist
+ fail(FileError.NOT_FOUND_ERR);
+ }
+
+ }else{
+ blackberry.io.file.copy(srcPath,dstPath);
+
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = false;
+ theEntry.isFile = true;
+ success(theEntry);
+ }
+ }else{
+ // file onto itself
+ fail(FileError.INVALID_MODIFICATION_ERR);
}
- else {
- // create entry for existing file
- createEntry();
+ }else{
+ if(srcPath != dstPath){
+ // allow back up to the root but not child dirs
+ if((parent.name != "root" && dstPath.indexOf(srcPath)>=0) || blackberry.io.file.exists(dstPath)){
+ // copying directory into child or is file path
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }else{
+ recursiveCopy(srcPath, dstPath);
+
+ theEntry.fullPath = dstPath;
+ theEntry.name = name;
+ theEntry.isDirectory = true;
+ theEntry.isFile = false;
+ success(theEntry);
+ }
+ }else{
+ // directory onto itself
+ fail(FileError.INVALID_MODIFICATION_ERR);
}
}
- // will return true if path exists AND is a directory
- else if (blackberry.io.dir.exists(path)) {
- // the path is a directory
- fail(FileError.TYPE_MISMATCH_ERR);
- }
- // path does not exist, create it
- else if (create) {
- // create empty file
- var emptyBlob = blackberry.utils.stringToBlob('');
- blackberry.io.file.saveFile(path,emptyBlob);
- createEntry();
- }
- // path does not exist, don't create
- else {
- // file doesn't exist
- fail(FileError.NOT_FOUND_ERR);
- }
+
},
- /**
- * Delete a directory and all of it's contents.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
- removeRecursively : function(successCallback, errorCallback) {
- // we're removing THIS directory
- var path = this.fullPath;
+ remove : function(successCallback, errorCallback) {
+ var path = this.fullPath,
+ // directory contents
+ contents = [];
var fail = function(error) {
if (typeof errorCallback === 'function') {
@@ -4814,1824 +4033,2367 @@ module.exports = {
}
};
- // attempt to delete directory
- if (blackberry.io.dir.exists(path)) {
+ // file
+ if (blackberry.io.file.exists(path)) {
+ try {
+ blackberry.io.file.deleteFile(path);
+ if (typeof successCallback === "function") {
+ successCallback();
+ }
+ } catch (e) {
+ // permissions don't allow
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ }
+ }
+ // directory
+ else if (blackberry.io.dir.exists(path)) {
// it is an error to attempt to remove the file system root
- //exec(null, null, "File", "isFileSystemRoot", [ path ]) === true
+ console.log('entry directory');
+ // TODO: gotta figure out how to get root dirs on playbook -
+ // getRootDirs doesn't work
if (false) {
fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
- }
- else {
- try {
- // delete the directory, setting recursive flag to true
- blackberry.io.dir.deleteDirectory(path, true);
- if (typeof successCallback === "function") {
- successCallback();
+ } else {
+ // check to see if directory is empty
+ contents = blackberry.io.dir.listFiles(path);
+ if (contents.length !== 0) {
+ fail(FileError.INVALID_MODIFICATION_ERR);
+ } else {
+ try {
+ // delete
+ blackberry.io.dir.deleteDirectory(path, false);
+ if (typeof successCallback === "function") {
+ successCallback();
+ }
+ } catch (eone) {
+ // permissions don't allow
+ fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
}
- } catch (e) {
- // permissions don't allow deletion
- console.log(e);
- fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
}
}
}
- // it's a file, not a directory
- else if (blackberry.io.file.exists(path)) {
- fail(FileError.TYPE_MISMATCH_ERR);
- }
// not found
else {
fail(FileError.NOT_FOUND_ERR);
}
+ },
+ getParent : function(successCallback, errorCallback) {
+ var that = this;
+
+ try {
+ // 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.
+ requestFileSystem(LocalFileSystem.TEMPORARY, 0,
+ function(fileSystem) {
+ if (fileSystem.root.fullPath === that.fullPath) {
+ if (typeof successCallback === 'function') {
+ successCallback(fileSystem.root);
+ }
+ } else {
+ resolveLocalFileSystemURI(blackberry.io.dir
+ .getParentDirectory(that.fullPath),
+ successCallback, errorCallback);
+ }
+ }, errorCallback);
+ } catch (e) {
+ if (typeof errorCallback === 'function') {
+ errorCallback(new FileError(FileError.NOT_FOUND_ERR));
+ }
+ }
}
};
-});
-// file: lib/playbook/plugin/playbook/DirectoryReader.js
-define("cordova/plugin/playbook/DirectoryReader", function(require, exports, module) {
-var FileError = require('cordova/plugin/FileError');
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
+});
+// file: lib/webworks/air/plugin/air/File.js
+define("cordova/plugin/air/File", function(require, exports, module) {
/**
- * 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
+ * Constructor.
+ * 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
*/
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- var theEntries = [];
- // Entry object is borked - unable to instantiate a new Entry object so just create one
- var anEntry = function (isDirectory, name, fullPath) {
- this.isDirectory = (isDirectory ? true : false);
- this.isFile = (isDirectory ? false : true);
- this.name = name;
- this.fullPath = fullPath;
- };
+var File = function(name, fullPath, type, lastModifiedDate, size){
+ this.name = name || '';
+ this.fullPath = fullPath || null;
+ this.type = type || null;
+ this.lastModifiedDate = lastModifiedDate || null;
+ this.size = size || 0;
+};
- if(blackberry.io.dir.exists(this.path)){
- var theDirectories = blackberry.io.dir.listDirectories(this.path);
- var theFiles = blackberry.io.dir.listFiles(this.path);
+module.exports = File;
+});
+
+// file: lib/webworks/air/plugin/air/FileEntry.js
+define("cordova/plugin/air/FileEntry", function(require, exports, module) {
+var FileEntry = require('cordova/plugin/FileEntry'),
+ Entry = require('cordova/plugin/air/Entry'),
+ FileWriter = require('cordova/plugin/air/FileWriter'),
+ File = require('cordova/plugin/air/File'),
+ FileError = require('cordova/plugin/FileError');
+
+module.exports = {
+ /**
+ * 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
+ */
+ createWriter : function(successCallback, errorCallback) {
+ this.file(function(filePointer) {
+ var writer = new FileWriter(filePointer);
+
+ if (writer.fileName === null || writer.fileName === "") {
+ if (typeof errorCallback === "function") {
+ errorCallback(new FileError(FileError.INVALID_STATE_ERR));
+ }
+ } else {
+ if (typeof successCallback === "function") {
+ successCallback(writer);
+ }
+ }
+ }, 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
+ */
+ file : function(successCallback, errorCallback) {
+ var win = typeof successCallback !== 'function' ? null : function(f) {
+ var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
+ successCallback(file);
+ };
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ errorCallback(new FileError(code));
+ };
- var theDirectoriesLength = theDirectories.length;
- var theFilesLength = theFiles.length;
- for(var i=0;i<theDirectoriesLength;i++){
- theEntries.push(new anEntry(true, theDirectories[i], this.path+theDirectories[i]));
- }
+ if(blackberry.io.file.exists(this.fullPath)){
+ var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
+ var theFile = {};
- for(var j=0;j<theFilesLength;j++){
- theEntries.push(new anEntry(false, theFiles[j], this.path+theFiles[j]));
+ theFile.fullPath = this.fullPath;
+ theFile.type = theFileProperties.fileExtension;
+ theFile.lastModifiedDate = theFileProperties.dateModified;
+ theFile.size = theFileProperties.size;
+ win(theFile);
+ }else{
+ fail(FileError.NOT_FOUND_ERR);
}
- win(theEntries);
- }else{
- fail(FileError.NOT_FOUND_ERR);
}
-
-
};
-module.exports = DirectoryReader;
});
-// file: lib/playbook/plugin/playbook/Entry.js
-define("cordova/plugin/playbook/Entry", function(require, exports, module) {
+// file: lib/webworks/air/plugin/air/FileReader.js
+define("cordova/plugin/air/FileReader", function(require, exports, module) {
var FileError = require('cordova/plugin/FileError'),
- LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
- Metadata = require('cordova/plugin/Metadata'),
- resolveLocalFileSystemURI = require('cordova/plugin/playbook/resolveLocalFileSystemURI'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- requestFileSystem = require('cordova/plugin/playbook/requestFileSystem');
+ ProgressEvent = require('cordova/plugin/ProgressEvent');
-var recursiveCopy = function(srcDirPath, dstDirPath){
- // get all the contents (file+dir) of the dir
- var files = blackberry.io.dir.listFiles(srcDirPath);
- var dirs = blackberry.io.dir.listDirectories(srcDirPath);
+/**
+ * This class reads the mobile device file system.
+ *
+ * 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
+ */
+var FileReader = function() {
+ this.fileName = "";
- for(var i=0;i<files.length;i++){
- blackberry.io.file.copy(srcDirPath + '/' + files[i], dstDirPath + '/' + files[i]);
- }
+ this.readyState = 0; // FileReader.EMPTY
- for(var j=0;j<dirs.length;j++){
- if(!blackberry.io.dir.exists(dstDirPath + '/' + dirs[j])){
- blackberry.io.dir.createNewDir(dstDirPath + '/' + dirs[j]);
- }
- recursiveCopy(srcDirPath + '/' + dirs[j], dstDirPath + '/' + dirs[j]);
- }
+ // File data
+ this.result = null;
+
+ // Error
+ this.error = null;
+
+ // Event handlers
+ this.onloadstart = null; // When the read starts.
+ this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progess.loaded/progress.total)
+ this.onload = null; // When the read has successfully completed.
+ this.onerror = null; // When the read has failed (see errors).
+ this.onloadend = null; // When the request has completed (either in success or failure).
+ this.onabort = null; // When the read has been aborted. Fo
<TRUNCATED>