incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [4/21] git commit: Updated for iOS Contacts
Date Thu, 15 Mar 2012 19:36:24 GMT
Updated for iOS Contacts

*Need to create a complete Contact object on return from save.
*Need to convert from JS Dates to milliseconds and vice versa when
roundtripping to device.


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/27c3628f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/27c3628f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/27c3628f

Branch: refs/heads/master
Commit: 27c3628f1fedf3ec1a7cde5d45f43b6b22384419
Parents: 5e84c3e
Author: Becky Gibson <becka11y@apache.org>
Authored: Tue Mar 13 13:40:23 2012 -0400
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Thu Mar 15 10:18:13 2012 -0700

----------------------------------------------------------------------
 lib/exec/ios.js       |    4 ++--
 lib/plugin/Contact.js |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/27c3628f/lib/exec/ios.js
----------------------------------------------------------------------
diff --git a/lib/exec/ios.js b/lib/exec/ios.js
index e97252c..32d8b6a 100644
--- a/lib/exec/ios.js
+++ b/lib/exec/ios.js
@@ -67,8 +67,8 @@ module.exports = function() {
     for (var i = 0; i < actionArgs.length; ++i) {
         var arg = actionArgs[i];
         if (arg == undefined || arg == null) { // nulls are pushed to the args now (becomes
NSNull)
-            command.arguments.push(arg);
-        } else if (typeof(arg) == 'object') {
+            continue;  //command.arguments.push(arg);
+        } else if (typeof(arg) == 'object' && !(arg instanceof Array)) {
             command.options = arg;
         } else {
             command.arguments.push(arg);

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/27c3628f/lib/plugin/Contact.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Contact.js b/lib/plugin/Contact.js
index 0c24e83..ece43b1 100644
--- a/lib/plugin/Contact.js
+++ b/lib/plugin/Contact.js
@@ -55,6 +55,40 @@ var Contact = function (id, displayName, name, nickname, phoneNumbers,
emails, a
     this.categories = categories || null; // ContactField[]
     this.urls = urls || null; // ContactField[]
 };
+/** 
+*	Converts Complex objects into primitives
+*   Only conversion at present is for Dates.
+**/
+Contact.prototype.convertOut = function() {
+	var value = this.birthday;
+    if (value != null) {
+    	// try to make it a Date object if it is not already
+    	if (!value instanceof Date){
+			try {
+				value = new Date(value);
+			} catch(exception){
+				value = null;
+			}
+		}
+		if (value instanceof Date){
+			value = value.valueOf(); // convert to milliseconds
+		}
+		this.birthday = value;
+    }
+};
+
+/**
+* Converts primitives into Complex Object
+* Currently only used for Date fields
+*/
+Contact.prototype.convertIn = function() {
+	var value = this.birthday;
+	try {
+		this.birthday = new Date(parseFloat(value));
+	} catch (exception){
+		console.log("exception creating date");
+	}            	    
+};
 
 /**
 * Removes contact from device storage.
@@ -148,7 +182,7 @@ Contact.prototype.save = function(successCB, errorCB) {
           fail(ContactError.UNKNOWN_ERROR);
       }
   };
-	var dupContact = this.clone();
+	var dupContact = utils.clone(this);
 	exec(success, fail, "Contacts", "save", [dupContact]);
 };
 


Mime
View raw message