You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/05/17 20:39:52 UTC
js commit: why you gotta do this to me pat?
Updated Branches:
refs/heads/master 2ba772d49 -> b1673e3e1
why you gotta do this to me pat?
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/b1673e3e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/b1673e3e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/b1673e3e
Branch: refs/heads/master
Commit: b1673e3e11dacc3e29b968f4139a8e8f8a5c23de
Parents: 2ba772d
Author: Fil Maj <ma...@gmail.com>
Authored: Thu May 17 11:43:14 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu May 17 11:43:14 2012 -0700
----------------------------------------------------------------------
lib/bada/plugin/bada/Contacts.js | 18 +++---
lib/common/plugin/logger.js | 109 ++++++++++++++++-----------------
lib/ios/platform.js | 4 +-
3 files changed, 65 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b1673e3e/lib/bada/plugin/bada/Contacts.js
----------------------------------------------------------------------
diff --git a/lib/bada/plugin/bada/Contacts.js b/lib/bada/plugin/bada/Contacts.js
index 77c452c..c6a21b4 100644
--- a/lib/bada/plugin/bada/Contacts.js
+++ b/lib/bada/plugin/bada/Contacts.js
@@ -7,7 +7,7 @@ var allowedFilters = ["firstName", "lastName", "phoneticName", "nickname", "phon
function _pgToWac(contact) {
var i, j;
var wacContact = {};
-
+
if(contact.id) {
wacContact.id = contact.id;
}
@@ -38,7 +38,7 @@ function _pgToWac(contact) {
}
}
}
-
+
// emails
if(contact.emails && contact.emails.length > 0) {
wacContact.emails = [];
@@ -88,11 +88,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 = {};
@@ -100,12 +100,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 = [];
@@ -122,7 +122,7 @@ function _wacToPg(contact) {
pgContact.phoneNumbers.push(pgPhoneNumber);
}
}
-
+
// emails
if(contact.emails && contact.emails.length > 0) {
pgContact.emails = [];
@@ -139,7 +139,7 @@ function _wacToPg(contact) {
pgContact.emails.push(pgEmailAddress);
}
}
-
+
// addresses
if(contact.addresses && contact.addresses.length > 0) {
pgContact.addresses = [];
@@ -160,7 +160,7 @@ function _wacToPg(contact) {
pgContact.addresses.push(pgAddress);
}
}
-
+
// photos
// can only store one photo URL
if(contact.photoURL) {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b1673e3e/lib/common/plugin/logger.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/logger.js b/lib/common/plugin/logger.js
index bcbc0cf..812fed3 100644
--- a/lib/common/plugin/logger.js
+++ b/lib/common/plugin/logger.js
@@ -19,15 +19,15 @@
//
//------------------------------------------------------------------------------
-var logger = exports
+var logger = exports;
-var exec = require('cordova/exec')
-var utils = require('cordova/utils')
+var exec = require('cordova/exec');
+var utils = require('cordova/utils');
-var UseConsole = true
-var Queued = []
-var DeviceReady = false
-var CurrentLevel
+var UseConsole = true;
+var Queued = [];
+var DeviceReady = false;
+var CurrentLevel;
/**
* Logging levels
@@ -39,21 +39,21 @@ var Levels = [
"WARN",
"INFO",
"DEBUG"
-]
+];
/*
* add the logging levels to the logger object and
* to a separate levelsMap object for testing
*/
-var LevelsMap = {}
+var LevelsMap = {};
for (var i=0; i<Levels.length; i++) {
- var level = Levels[i]
- LevelsMap[level] = i
- logger[level] = level
+ var level = Levels[i];
+ LevelsMap[level] = i;
+ logger[level] = level;
}
-CurrentLevel = LevelsMap["WARN"]
+CurrentLevel = LevelsMap.WARN;
/**
* Getter/Setter for the logging level
@@ -76,15 +76,14 @@ CurrentLevel = LevelsMap["WARN"]
*/
logger.level = function (value) {
if (arguments.length) {
- if (LevelsMap[value] == null) {
- throw new Error("invalid logging level: " + value)
+ if (LevelsMap[value] === null) {
+ throw new Error("invalid logging level: " + value);
}
- CurrentLevel = LevelsMap[value]
+ CurrentLevel = LevelsMap[value];
}
- return Levels[CurrentLevel]
-}
-
+ return Levels[CurrentLevel];
+};
/**
* Getter/Setter for the useConsole functionality
@@ -94,24 +93,24 @@ logger.level = function (value) {
* native Logger plugin.
*/
logger.useConsole = function (value) {
- if (arguments.length) UseConsole = !!value
+ if (arguments.length) UseConsole = !!value;
if (UseConsole) {
if (typeof console == "undefined") {
- throw new Error("global console object is not defined")
+ 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")
+ throw new Error("global console object does not have a log function");
}
if (console.__usingCordovaLogger) {
- throw new Error("console and logger are too intertwingly")
+ throw new Error("console and logger are too intertwingly");
}
}
- return UseConsole
-}
+ return UseConsole;
+};
/**
* Logs a message at the LOG level.
@@ -119,7 +118,7 @@ logger.useConsole = function (value) {
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.log = function(message) { logWithArgs("LOG", arguments) }
+logger.log = function(message) { logWithArgs("LOG", arguments); };
/**
* Logs a message at the ERROR level.
@@ -127,7 +126,7 @@ logger.log = function(message) { logWithArgs("LOG", arguments) }
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.error = function(message) { logWithArgs("ERROR", arguments) }
+logger.error = function(message) { logWithArgs("ERROR", arguments); };
/**
* Logs a message at the WARN level.
@@ -135,7 +134,7 @@ logger.error = function(message) { logWithArgs("ERROR", arguments) }
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.warn = function(message) { logWithArgs("WARN", arguments) }
+logger.warn = function(message) { logWithArgs("WARN", arguments); };
/**
* Logs a message at the INFO level.
@@ -143,7 +142,7 @@ logger.warn = function(message) { logWithArgs("WARN", arguments) }
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.info = function(message) { logWithArgs("INFO", arguments) }
+logger.info = function(message) { logWithArgs("INFO", arguments); };
/**
* Logs a message at the DEBUG level.
@@ -151,12 +150,12 @@ logger.info = function(message) { logWithArgs("INFO", arguments) }
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.debug = function(message) { logWithArgs("DEBUG", arguments) }
+logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
// log at the specified level with args
function logWithArgs(level, args) {
- var args = [level].concat([].slice.call(args))
- logger.logLevel.apply(logger, args)
+ args = [level].concat([].slice.call(args));
+ logger.logLevel.apply(logger, args);
}
/**
@@ -167,55 +166,55 @@ function logWithArgs(level, args) {
*/
logger.logLevel = function(level, message /* , ... */) {
// format the message with the parameters
- var formatArgs = [].slice.call(arguments, 2)
- var message = utils.vformat(message, formatArgs)
+ 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] === null) {
+ throw new Error("invalid logging level: " + level);
}
- if (LevelsMap[level] > CurrentLevel) return
+ if (LevelsMap[level] > CurrentLevel) return;
// queue the message if not yet at deviceready
if (!DeviceReady && !UseConsole) {
- Queued.push([level, message])
- return
+ Queued.push([level, message]);
+ return;
}
// if not using the console, use the native logger
if (!UseConsole) {
- exec(null, null, "Logger", "logLevel", [level, message])
- return
+ 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")
+ 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
+ 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
+ if (DeviceReady) return;
- DeviceReady = true
+ DeviceReady = true;
for (var i=0; i<Queued.length; i++) {
- var messageArgs = Queued[i]
- logger.logLevel(messageArgs[0], messageArgs[1])
+ var messageArgs = Queued[i];
+ logger.logLevel(messageArgs[0], messageArgs[1]);
}
- Queued = null
-}
+ Queued = null;
+};
// add a deviceready event to log queued messages
-document.addEventListener("deviceready", logger.__onDeviceReady, false)
\ No newline at end of file
+document.addEventListener("deviceready", logger.__onDeviceReady, false);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b1673e3e/lib/ios/platform.js
----------------------------------------------------------------------
diff --git a/lib/ios/platform.js b/lib/ios/platform.js
index d31c49c..128b2c2 100644
--- a/lib/ios/platform.js
+++ b/lib/ios/platform.js
@@ -47,5 +47,5 @@ module.exports = {
};
// use the native logger
-var logger = require("cordova/plugin/logger")
-logger.useConsole(false)
\ No newline at end of file
+var logger = require("cordova/plugin/logger");
+logger.useConsole(false);