You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/05/25 19:01:35 UTC
[6/6] bada-wac commit: adding latest cordovajs
adding latest cordovajs
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/commit/23bb3e5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/tree/23bb3e5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/diff/23bb3e5f
Branch: refs/heads/master
Commit: 23bb3e5f38a92fa1870b612af37cceb0e2a1f0a0
Parents: c4f7a09
Author: Anis Kadri <an...@gmail.com>
Authored: Fri May 25 09:47:23 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Fri May 25 09:47:23 2012 -0700
----------------------------------------------------------------------
Res/js/cordova.bada.js | 827 +++++++++++++++++++++++++++++++++++++------
1 files changed, 727 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/23bb3e5f/Res/js/cordova.bada.js
----------------------------------------------------------------------
diff --git a/Res/js/cordova.bada.js b/Res/js/cordova.bada.js
index 507f002..c16f536 100644
--- a/Res/js/cordova.bada.js
+++ b/Res/js/cordova.bada.js
@@ -1,6 +1,6 @@
-// commit 71d806e61e5240ccf9f6299500741b68ea9c5d3d
+// commit 3edbc444b2091f11f149dea225b0ad8da4120f71
-// File generated at :: Fri May 11 2012 08:12:45 GMT-0700 (Pacific Daylight Time)
+// File generated at :: Fri May 25 2012 09:44:15 GMT-0700 (Pacific Daylight Time)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -98,17 +98,7 @@ var documentEventHandlers = {},
document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
- if (e == 'deviceready') {
- channel.onDeviceReady.subscribeOnce(handler);
- } else if (e == 'resume') {
- channel.onResume.subscribe(handler);
- // if subscribing listener after event has already fired, invoke the handler
- if (channel.onResume.fired && typeof handler == 'function') {
- handler();
- }
- } else if (e == 'pause') {
- channel.onPause.subscribe(handler);
- } else if (typeof documentEventHandlers[e] != 'undefined') {
+ if (typeof documentEventHandlers[e] != 'undefined') {
documentEventHandlers[e].subscribe(handler);
} else {
m_document_addEventListener.call(document, evt, handler, capture);
@@ -126,13 +116,8 @@ window.addEventListener = function(evt, handler, capture) {
document.removeEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
- // Check for pause/resume events first.
- if (e == 'resume') {
- channel.onResume.unsubscribe(handler);
- } else if (e == 'pause') {
- channel.onPause.unsubscribe(handler);
// If unsubcribing from an event that is handled by a plugin
- } else if (typeof documentEventHandlers[e] != "undefined") {
+ if (typeof documentEventHandlers[e] != "undefined") {
documentEventHandlers[e].unsubscribe(handler);
} else {
m_document_removeEventListener.call(document, evt, handler, capture);
@@ -318,6 +303,11 @@ var cordova = {
}
};
+// Register pause, resume and deviceready channels as events on document.
+channel.onPause = cordova.addDocumentEventHandler('pause');
+channel.onResume = cordova.addDocumentEventHandler('resume');
+channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
+
// Adds deprecation warnings to functions of an object (but only logs a message once)
function deprecateFunctions(obj, objLabel) {
var newObj = {};
@@ -721,6 +711,9 @@ module.exports = {
children: {
exec: {
path: 'cordova/exec'
+ },
+ logger: {
+ path: 'cordova/plugin/logger'
}
}
},
@@ -924,7 +917,9 @@ var plugins = {
"Compass": require('cordova/plugin/bada/Compass'),
"Capture": require('cordova/plugin/bada/Capture'),
"Camera": require('cordova/plugin/bada/Camera'),
- "Contacts": require('cordova/plugin/bada/Contacts')
+ "Contacts": require('cordova/plugin/bada/Contacts'),
+ "File": require('cordova/plugin/bada/File'),
+ "FileTransfer": require('cordova/plugin/bada/FileTransfer')
};
module.exports = function(success, fail, service, action, args) {
@@ -973,13 +968,14 @@ module.exports = {
// file: lib\common\plugin\Acceleration.js
define("cordova/plugin/Acceleration", function(require, exports, module) {
var Acceleration = function(x, y, z, timestamp) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = timestamp || (new Date()).getTime();
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.timestamp = timestamp || (new Date()).getTime();
};
module.exports = Acceleration;
+
});
// file: lib\common\plugin\Camera.js
@@ -998,7 +994,7 @@ for (var key in Camera) {
* Gets a picture from source defined by "options.sourceType", and returns the
* image as defined by the "options.destinationType" option.
- * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
+ * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
*
* @param {Function} successCallback
* @param {Function} errorCallback
@@ -1944,7 +1940,7 @@ Entry.prototype.toURL = function() {
Entry.prototype.toURI = function(mimeType) {
console.log("DEPRECATED: Update your code to use 'toURL'");
// fullPath attribute contains the full URI
- return this.fullPath;
+ return this.toURL();
};
/**
@@ -3198,11 +3194,60 @@ define("cordova/plugin/accelerometer", function(require, exports, module) {
* @constructor
*/
var utils = require("cordova/utils"),
- exec = require("cordova/exec");
+ exec = require("cordova/exec"),
+ Acceleration = require('cordova/plugin/Acceleration');
+
+// Is the accel sensor running?
+var running = false;
-// Local singleton variables.
+// Keeps reference to watchAcceleration calls.
var timers = {};
+// Array of listeners; used to keep track of when we should call start and stop.
+var listeners = [];
+
+// Last returned acceleration object from native
+var accel = null;
+
+// Tells native to start.
+function start() {
+ exec(function(a) {
+ var tempListeners = listeners.slice(0);
+ accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].win(accel);
+ }
+ }, function(e) {
+ var tempListeners = listeners.slice(0);
+ for (var i = 0, l = tempListeners.length; i < l; i++) {
+ tempListeners[i].fail(e);
+ }
+ }, "Accelerometer", "start", []);
+ running = true;
+}
+
+// Tells native to stop.
+function stop() {
+ exec(null, null, "Accelerometer", "stop", []);
+ running = false;
+}
+
+// Adds a callback pair to the listeners array
+function createCallbackPair(win, fail) {
+ return {win:win, fail:fail};
+}
+
+// Removes a win/fail listener pair from the listeners array
+function removeListeners(l) {
+ var idx = listeners.indexOf(l);
+ if (idx > -1) {
+ listeners.splice(idx, 1);
+ if (listeners.length === 0) {
+ stop();
+ }
+ }
+}
+
var accelerometer = {
/**
* Asynchronously aquires the current acceleration.
@@ -3212,21 +3257,27 @@ var accelerometer = {
* @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
*/
getCurrentAcceleration: function(successCallback, errorCallback, options) {
-
// successCallback required
if (typeof successCallback !== "function") {
- console.log("Accelerometer Error: successCallback is not a function");
- return;
+ throw "getCurrentAcceleration must be called with at least a success callback function as first parameter.";
}
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Accelerometer Error: errorCallback is not a function");
- return;
- }
+ var p;
+ var win = function(a) {
+ successCallback(a);
+ removeListeners(p);
+ };
+ var fail = function(e) {
+ errorCallback(e);
+ removeListeners(p);
+ };
+
+ p = createCallbackPair(win, fail);
+ listeners.push(p);
- // Get acceleration
- exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
+ if (!running) {
+ start();
+ }
},
/**
@@ -3238,36 +3289,38 @@ var accelerometer = {
* @return String The watch id that must be passed to #clearWatch to stop watching.
*/
watchAcceleration: function(successCallback, errorCallback, options) {
-
// Default interval (10 sec)
- var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000;
+ var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
// successCallback required
if (typeof successCallback !== "function") {
- console.log("Accelerometer Error: successCallback is not a function");
- return;
+ throw "watchAcceleration must be called with at least a success callback function as first parameter.";
}
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Accelerometer Error: errorCallback is not a function");
- return;
- }
+ // Keep reference to watch id, and report accel readings as often as defined in frequency
+ var id = utils.createUUID();
+
+ var p = createCallbackPair(function(){}, function(e) {
+ errorCallback(e);
+ removeListeners(p);
+ });
+ listeners.push(p);
- // Make sure accelerometer timeout > frequency + 10 sec
- exec(
- function(timeout) {
- if (timeout < (frequency + 10000)) {
- exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
+ timers[id] = {
+ timer:window.setInterval(function() {
+ if (accel) {
+ successCallback(accel);
}
- },
- function(e) { }, "Accelerometer", "getTimeout", []);
+ }, frequency),
+ listeners:p
+ };
- // Start watch timer
- var id = utils.createUUID();
- timers[id] = window.setInterval(function() {
- exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
- }, (frequency ? frequency : 1));
+ if (running) {
+ // If we're already running then immediately invoke the success callback
+ successCallback(accel);
+ } else {
+ start();
+ }
return id;
},
@@ -3278,16 +3331,17 @@ var accelerometer = {
* @param {String} id The id of the watch returned from #watchAcceleration.
*/
clearWatch: function(id) {
-
// Stop javascript timer & remove from timer list
- if (id && timers[id] !== undefined) {
- window.clearInterval(timers[id]);
+ if (id && timers[id]) {
+ window.clearInterval(timers[id].timer);
+ removeListeners(timers[id].listeners);
delete timers[id];
}
}
};
module.exports = accelerometer;
+
});
// file: lib\bada\plugin\bada\Accelerometer.js
@@ -3504,7 +3558,7 @@ var allowedFilters = ["firstName", "lastName", "phoneticName", "nickname", "phon
function _pgToWac(contact) {
var i, j;
var wacContact = {};
-
+
if(contact.id) {
wacContact.id = contact.id;
}
@@ -3535,7 +3589,7 @@ function _pgToWac(contact) {
}
}
}
-
+
// emails
if(contact.emails && contact.emails.length > 0) {
wacContact.emails = [];
@@ -3585,11 +3639,11 @@ function _pgToWac(contact) {
function _wacToPg(contact) {
var i, j;
var pgContact = {};
-
+
if(contact.id) {
pgContact.id = contact.id;
}
-
+
// name
if(contact.firstName || contact.lastName) {
pgContact.name = {};
@@ -3597,12 +3651,12 @@ function _wacToPg(contact) {
pgContact.name.familyName = contact.lastName;
pgContact.displayName = contact.firstName + ' ' + contact.lastName;
}
-
+
// nicknames
if(contact.nicknames && contact.nicknames.length > 0) {
pgContact.nickname = contact.nicknames[0];
}
-
+
// phoneNumbers
if(contact.phoneNumbers && contact.phoneNumbers.length > 0) {
pgContact.phoneNumbers = [];
@@ -3619,7 +3673,7 @@ function _wacToPg(contact) {
pgContact.phoneNumbers.push(pgPhoneNumber);
}
}
-
+
// emails
if(contact.emails && contact.emails.length > 0) {
pgContact.emails = [];
@@ -3636,7 +3690,7 @@ function _wacToPg(contact) {
pgContact.emails.push(pgEmailAddress);
}
}
-
+
// addresses
if(contact.addresses && contact.addresses.length > 0) {
pgContact.addresses = [];
@@ -3657,7 +3711,7 @@ function _wacToPg(contact) {
pgContact.addresses.push(pgAddress);
}
}
-
+
// photos
// can only store one photo URL
if(contact.photoURL) {
@@ -3702,7 +3756,6 @@ module.exports = {
deviceapis.pim.contact.getAddressBooks(gotBooks, gotError);
},
remove: function(success, fail, params) {
- console.log("Contacts:remove "+JSON.stringify(params));
var id = params[0];
var gotBooks = function(books) {
var book = books[0];
@@ -3716,7 +3769,7 @@ module.exports = {
if(contacts.length === 1) {
book.deleteContact(removeSuccess, removeError, contacts[0].id);
}
- }
+ };
if(id) {
book.findContacts(toDelete, removeError, {id: id});
}
@@ -3754,37 +3807,196 @@ module.exports = {
});
+// file: lib\bada\plugin\bada\File.js
+define("cordova/plugin/bada/File", function(require, exports, module) {
+var LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
+ FileSystem = require('cordova/plugin/FileSystem');
+
+module.exports = {
+ /*
+ * @params: [type, size]
+ */
+ requestFileSystem: function(success, fail, params) {
+ console.log("File.requestFileSystem");
+ var type = params[0];
+ var name = "wgt-private";
+
+ if(type === LocalFileSystem.TEMPORARY) {
+ name = "wgt-private-tmp";
+ }
+ var resolveSuccess = function(dir) {
+ success({name: name, root: {name: name, fullPath: dir.fullPath}});
+ };
+ var resolveError = function(e) {
+ fail(e);
+ };
+ deviceapis.filesystem.resolve(resolveSuccess, resolveError, name, 'r');
+ },
+ /*
+ * @params: [fullPath, path, options]
+ */
+ getDirectory: function(success, fail, params) {
+ console.log("File.getDirectory");
+ var fullPath = params[0],
+ path = params[1],
+ options = params[2];
+ var resolveSuccess = function(dir) {
+ dir.createDirectory(path);
+ };
+ var resolveError = function(e) {
+ fail(e);
+ };
+ deviceapis.filesystem.resolve(resolveSuccess, resolveError, fullPath, 'rw');
+ },
+ /*
+ * @params: fullPath
+ */
+ removeRecursively: function(success, fail, params) {
+ console.log("File.removeRecursively");
+
+ },
+ /*
+ * @params: fullPath, path, options
+ */
+ getFile: function(success, fail, params) {
+ console.log("File.getFile");
+
+ },
+ /*
+ * @params: fullPath, path, options
+ */
+ readEntries: function(success, fail, params) {
+ console.log("File.readEntries");
+ },
+ /*
+ * @params: fullPath
+ */
+ getFileMetadata: function(success, fail, params) {
+ console.log("File.getFileMetadata");
+ },
+ /*
+ * @params: fullPath
+ */
+ getMetadata: function(success, fail, params) {
+ console.log("File.getMetadata");
+ },
+ /*
+ * @params: fullPath, metadataObject
+ */
+ setMetadata: function(success, fail, params) {
+ console.log("File.setMetadata");
+ },
+ /*
+ * @params: [fileName, enc]
+ */
+ readAsText: function(success, fail, params) {
+ console.log("File.readAsText");
+ },
+ /*
+ * @params: [srcPath, parent.fullPath, name]
+ */
+ moveTo: function(success, fail, params) {
+ console.log("File.moveTo");
+ },
+ /*
+ * @params: [srcPath, parent.fullPath, name]
+ */
+ copyTo: function(success, fail, params) {
+ console.log("File.copyTo");
+ },
+ /*
+ * @params: [fullPath]
+ */
+ remove: function(success, fail, params) {
+ console.log("File.remove");
+ },
+ /*
+ * @params: [fullPath]
+ */
+ getParent: function(success, fail, params) {
+ console.log("File.getParent");
+ },
+ /*
+ * @params: fileName
+ */
+ readAsDataURL: function(success, fail, params) {
+ console.log("File.readAsDataURL");
+ },
+ /*
+ * @params: fileName, text, position
+ */
+ write: function(success, fail, params) {
+ console.log("File.write");
+ },
+ /*
+ * @params: fileName, size
+ */
+ truncate: function(success, fail, params) {
+ console.log("File.truncate");
+ }
+};
+
+});
+
+// file: lib\bada\plugin\bada\FileTransfer.js
+define("cordova/plugin/bada/FileTransfer", function(require, exports, module) {
+module.exports = {
+ /*
+ * @params: filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode
+ */
+ upload: function(success, fail, params) {
+ console.log("FileTransfer.upload");
+ },
+ /*
+ * @params: source, target
+ */
+ download: function(success, fail, params) {
+ console.log("FileTransfer.download");
+ }
+};
+
+});
+
// file: lib\bada\plugin\bada\NetworkStatus.js
define("cordova/plugin/bada/NetworkStatus", function(require, exports, module) {
-var channel = require('cordova/channel');
+var channel = require('cordova/channel'),
+ Connection = require("cordova/plugin/Connection");
// We can't tell if a cell connection is 2,3 or 4G.
// We just know if it's connected and the signal strength
-// if it's roaming and the network name etc..so unless wifi we default to UNKNOWN
+// if it's roaming and the network name etc..so unless wifi we default to CELL_2G
+// if connected to cellular network
module.exports = {
getConnectionInfo: function(success, fail) {
- var Connection = require("cordova/plugin/Connection");
- var connectionType = Connection.NONE;
- deviceapis.devicestatus.getPropertyValue(function(value) {
- //console.log("Device WiFi network status: "+value);
- if(value == "connected") {
- connectionType = Connection.WIFI;
- }
- channel.onCordovaConnectionReady.fire();
- success(connectionType);
- },
- function(error) {
- console.log(JSON.stringify(error));
- fail();
- } , {aspect: "WiFiNetwork", property: "networkStatus"}
- );
- //info.getPropertyValue(function(value) {
- //console.log("Device Cellular network status: "+value);
- //if(signalStrength > 10) {
- //self.type = Connection.CELL_3G;
- //}
- //}, fail, {aspect: "CellularNetwork", property: "signalStrength"});
+ var connectionType = Connection.NONE;
+ var networkInfo = ["cellular", "wifi"]; // might be a better way to do this
+ var gotConnectionInfo = function() {
+ networkInfo.pop();
+ if(networkInfo.length === 0) {
+ channel.onCordovaConnectionReady.fire();
+ success(connectionType);
+ }
+ };
+ var error = function(e) {
+ console.log("Error "+e.message);
+ gotConnectionInfo();
+ };
+ deviceapis.devicestatus.getPropertyValue(function(value) {
+ console.log("Device Cellular network status: "+value);
+ if(connectionType === Connection.NONE) {
+ connectionType = Connection.CELL_2G;
+ }
+ gotConnectionInfo();
+ }, error, {aspect: "CellularNetwork", property: "signalStrength"});
+
+ deviceapis.devicestatus.getPropertyValue(function(value) {
+ console.log("Device WiFi network status: "+value);
+ if(value == "connected") {
+ connectionType = Connection.WIFI;
+ }
+ gotConnectionInfo();
+ }, error, {aspect: "WiFiNetwork", property: "networkStatus"});
}
};
@@ -4207,6 +4419,177 @@ var exec = require('cordova/exec'),
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'),
@@ -4468,6 +4851,233 @@ 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");
+ }
+ }
+ }
+
+ 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\common\plugin\network.js
define("cordova/plugin/network", function(require, exports, module) {
var exec = require('cordova/exec'),
@@ -4634,6 +5244,7 @@ var requestFileSystem = function(type, size, successCallback, errorCallback) {
};
module.exports = requestFileSystem;
+
});
// file: lib\common\plugin\resolveLocalFileSystemURI.js
@@ -4656,10 +5267,16 @@ module.exports = function(uri, successCallback, errorCallback) {
errorCallback(new FileError(error));
}
};
+ // sanity check for 'not:valid:filename'
+ if(!uri || uri.split(":").length > 2) {
+ setTimeout( function() {
+ fail(FileError.ENCODING_ERR);
+ },0);
+ return;
+ }
// if successful, return either a file or directory entry
var success = function(entry) {
var result;
-
if (entry) {
if (typeof successCallback === 'function') {
// create appropriate Entry object
@@ -4797,6 +5414,16 @@ utils.alert = function(msg) {
/**
* Formats a string and arguments following it ala sprintf()
*
+ * see utils.vformat() for more information
+ */
+utils.format = function(formatString /* ,... */) {
+ var args = [].slice.call(arguments, 1);
+ return utils.vformat(formatString, args);
+};
+
+/**
+ * Formats a string and arguments following it ala vsprintf()
+ *
* format chars:
* %j - format arg as JSON
* %o - format arg as JSON
@@ -4808,14 +5435,13 @@ utils.alert = function(msg) {
* for rationale, see FireBug's Console API:
* http://getfirebug.com/wiki/index.php/Console_API
*/
-utils.format = function(formatString /* ,... */) {
+utils.vformat = function(formatString, args) {
if (formatString === null || formatString === undefined) return "";
if (arguments.length == 1) return formatString.toString();
var pattern = /(.*?)%(.)(.*)/;
var rest = formatString.toString();
var result = [];
- var args = [].slice.call(arguments,1);
while (args.length) {
var arg = args.shift();
@@ -4908,7 +5534,7 @@ window.cordova = require('cordova');
// Fire onDeviceReady event once all constructors have run and
// cordova info has been received from native side.
channel.join(function() {
- channel.onDeviceReady.fire();
+ require('cordova').fireDocumentEvent('deviceready');
}, channel.deviceReadyChannelsArray);
}, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
@@ -4926,6 +5552,7 @@ window.cordova = require('cordova');
}
}(window));
+
// file: lib\scripts\bootstrap-bada.js
require('cordova/channel').onNativeReady.fire();