Updated Branches: refs/heads/master 42bbcbf58 -> cef76ff1b
reverting to old javascript and updating VERSION 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/cef76ff1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/tree/cef76ff1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/diff/cef76ff1 Branch: refs/heads/master Commit: cef76ff1be59026d316859a53cb90a8e0b20d134 Parents: 42bbcbf Author: Anis Kadri <anis.ka...@gmail.com> Authored: Tue Jun 5 16:18:39 2012 -0700 Committer: Anis Kadri <anis.ka...@gmail.com> Committed: Tue Jun 5 16:18:39 2012 -0700 ---------------------------------------------------------------------- Res/js/cordova.js | 830 ++++++------------------------------------------ VERSION | 2 +- 2 files changed, 104 insertions(+), 728 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/cef76ff1/Res/js/cordova.js ---------------------------------------------------------------------- diff --git a/Res/js/cordova.js b/Res/js/cordova.js index db194f9..507f002 100644 --- a/Res/js/cordova.js +++ b/Res/js/cordova.js @@ -1,6 +1,6 @@ -// commit c2cbb549fff51fc1aa6bee9162adf5ef5a727fb4 +// commit 71d806e61e5240ccf9f6299500741b68ea9c5d3d -// File generated at :: Fri May 25 2012 10:08:19 GMT-0700 (Pacific Daylight Time) +// File generated at :: Fri May 11 2012 08:12:45 GMT-0700 (Pacific Daylight Time) /* Licensed to the Apache Software Foundation (ASF) under one @@ -98,7 +98,17 @@ var documentEventHandlers = {}, document.addEventListener = function(evt, handler, capture) { var e = evt.toLowerCase(); - if (typeof documentEventHandlers[e] != 'undefined') { + 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') { documentEventHandlers[e].subscribe(handler); } else { m_document_addEventListener.call(document, evt, handler, capture); @@ -116,8 +126,13 @@ 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 - if (typeof documentEventHandlers[e] != "undefined") { + } else if (typeof documentEventHandlers[e] != "undefined") { documentEventHandlers[e].unsubscribe(handler); } else { m_document_removeEventListener.call(document, evt, handler, capture); @@ -303,11 +318,6 @@ 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 = {}; @@ -711,9 +721,6 @@ module.exports = { children: { exec: { path: 'cordova/exec' - }, - logger: { - path: 'cordova/plugin/logger' } } }, @@ -950,9 +957,9 @@ module.exports = { device: { path: "cordova/plugin/bada/device" }, - camera: { - path: "cordova/plugin/bada/Camera" - }, +// camera: { +// path: "cordova/plugin/bada/Camera" +// }, capture: { path: "cordova/plugin/bada/Capture" } @@ -966,14 +973,13 @@ 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 @@ -992,7 +998,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_URI. + * The defaults are sourceType=CAMERA and destinationType=FILE_URL. * * @param {Function} successCallback * @param {Function} errorCallback @@ -1938,7 +1944,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.toURL(); + return this.fullPath; }; /** @@ -3192,60 +3198,11 @@ define("cordova/plugin/accelerometer", function(require, exports, module) { * @constructor */ var utils = require("cordova/utils"), - exec = require("cordova/exec"), - Acceleration = require('cordova/plugin/Acceleration'); + exec = require("cordova/exec"); -// Is the accel sensor running? -var running = false; - -// Keeps reference to watchAcceleration calls. +// Local singleton variables. 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. @@ -3255,27 +3212,21 @@ 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") { - throw "getCurrentAcceleration must be called with at least a success callback function as first parameter."; + console.log("Accelerometer Error: successCallback 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); - - if (!running) { - start(); + // errorCallback optional + if (errorCallback && (typeof errorCallback !== "function")) { + console.log("Accelerometer Error: errorCallback is not a function"); + return; } + + // Get acceleration + exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []); }, /** @@ -3287,38 +3238,36 @@ 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 && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000; + var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000; // successCallback required if (typeof successCallback !== "function") { - throw "watchAcceleration must be called with at least a success callback function as first parameter."; + console.log("Accelerometer Error: successCallback 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); + // errorCallback optional + if (errorCallback && (typeof errorCallback !== "function")) { + console.log("Accelerometer Error: errorCallback is not a function"); + return; + } - timers[id] = { - timer:window.setInterval(function() { - if (accel) { - successCallback(accel); + // Make sure accelerometer timeout > frequency + 10 sec + exec( + function(timeout) { + if (timeout < (frequency + 10000)) { + exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]); } - }, frequency), - listeners:p - }; + }, + function(e) { }, "Accelerometer", "getTimeout", []); - if (running) { - // If we're already running then immediately invoke the success callback - successCallback(accel); - } else { - start(); - } + // Start watch timer + var id = utils.createUUID(); + timers[id] = window.setInterval(function() { + exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []); + }, (frequency ? frequency : 1)); return id; }, @@ -3329,17 +3278,16 @@ 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]) { - window.clearInterval(timers[id].timer); - removeListeners(timers[id].listeners); + if (id && timers[id] !== undefined) { + window.clearInterval(timers[id]); delete timers[id]; } } }; module.exports = accelerometer; - }); // file: lib\bada\plugin\bada\Accelerometer.js @@ -3556,7 +3504,7 @@ var allowedFilters = ["firstName", "lastName", "phoneticName", "nickname", "phon function _pgToWac(contact) { var i, j; var wacContact = {}; - + if(contact.id) { wacContact.id = contact.id; } @@ -3587,7 +3535,7 @@ function _pgToWac(contact) { } } } - + // emails if(contact.emails && contact.emails.length > 0) { wacContact.emails = []; @@ -3637,11 +3585,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 = {}; @@ -3649,12 +3597,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 = []; @@ -3671,7 +3619,7 @@ function _wacToPg(contact) { pgContact.phoneNumbers.push(pgPhoneNumber); } } - + // emails if(contact.emails && contact.emails.length > 0) { pgContact.emails = []; @@ -3688,7 +3636,7 @@ function _wacToPg(contact) { pgContact.emails.push(pgEmailAddress); } } - + // addresses if(contact.addresses && contact.addresses.length > 0) { pgContact.addresses = []; @@ -3709,7 +3657,7 @@ function _wacToPg(contact) { pgContact.addresses.push(pgAddress); } } - + // photos // can only store one photo URL if(contact.photoURL) { @@ -3754,6 +3702,7 @@ 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]; @@ -3767,7 +3716,7 @@ module.exports = { if(contacts.length === 1) { book.deleteContact(removeSuccess, removeError, contacts[0].id); } - }; + } if(id) { book.findContacts(toDelete, removeError, {id: id}); } @@ -3805,196 +3754,37 @@ 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'), - Connection = require("cordova/plugin/Connection"); +var channel = require('cordova/channel'); // 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 CELL_2G -// if connected to cellular network +// if it's roaming and the network name etc..so unless wifi we default to UNKNOWN module.exports = { getConnectionInfo: function(success, fail) { - 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"}); + 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"}); } }; @@ -4108,7 +3898,7 @@ Device.prototype.getInfo = function(success, fail, args) { me.platform = os_vendor + " " + os_name; me.version = os_version; me.uuid = uuid; - me.cordova = "1.8.0"; + me.cordova = "1.7.0"; success(me); } }; @@ -4417,177 +4207,6 @@ 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'), @@ -4849,233 +4468,6 @@ 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'), @@ -5264,16 +4656,10 @@ 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 @@ -5411,16 +4797,6 @@ 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 @@ -5432,13 +4808,14 @@ utils.format = function(formatString /* ,... */) { * for rationale, see FireBug's Console API: * http://getfirebug.com/wiki/index.php/Console_API */ -utils.vformat = function(formatString, args) { +utils.format = function(formatString /* ,... */) { 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(); @@ -5531,7 +4908,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() { - require('cordova').fireDocumentEvent('deviceready'); + channel.onDeviceReady.fire(); }, channel.deviceReadyChannelsArray); }, [ channel.onDOMContentLoaded, channel.onNativeReady ]); @@ -5549,7 +4926,6 @@ window.cordova = require('cordova'); } }(window)); - // file: lib\scripts\bootstrap-bada.js require('cordova/channel').onNativeReady.fire(); http://git-wip-us.apache.org/repos/asf/incubator-cordova-bada-wac/blob/cef76ff1/VERSION ---------------------------------------------------------------------- diff --git a/VERSION b/VERSION index 92f201f..27f9cd3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.0rc1 +1.8.0