You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/10 15:34:13 UTC

js commit: [all] Add argscheck to Contact.js

Updated Branches:
  refs/heads/master dc99f7631 -> 221849c28


[all] Add argscheck to Contact.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/221849c2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/221849c2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/221849c2

Branch: refs/heads/master
Commit: 221849c288a373d6da7cec0b540d28325a971a19
Parents: dc99f76
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Dec 14 15:18:33 2012 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jan 10 09:34:09 2013 -0500

----------------------------------------------------------------------
 lib/common/plugin/Contact.js |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/221849c2/lib/common/plugin/Contact.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/Contact.js b/lib/common/plugin/Contact.js
index 70dac7a..f0e2d65 100644
--- a/lib/common/plugin/Contact.js
+++ b/lib/common/plugin/Contact.js
@@ -19,7 +19,8 @@
  *
 */
 
-var exec = require('cordova/exec'),
+var argscheck = require('cordova/argscheck'),
+    exec = require('cordova/exec'),
     ContactError = require('cordova/plugin/ContactError'),
     utils = require('cordova/utils');
 
@@ -104,7 +105,8 @@ var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, a
 * @param errorCB error callback
 */
 Contact.prototype.remove = function(successCB, errorCB) {
-    var fail = function(code) {
+    argscheck.checkArgs('FF', 'Contact.remove', arguments);
+    var fail = errorCB && function(code) {
         errorCB(new ContactError(code));
     };
     if (this.id === null) {
@@ -151,21 +153,22 @@ Contact.prototype.clone = function() {
 * @param errorCB error callback
 */
 Contact.prototype.save = function(successCB, errorCB) {
-  var fail = function(code) {
-      errorCB(new ContactError(code));
-  };
+    argscheck.checkArgs('FFO', 'Contact.save', arguments);
+    var fail = errorCB && function(code) {
+        errorCB(new ContactError(code));
+    };
     var success = function(result) {
-      if (result) {
-          if (typeof successCB === 'function') {
-              var fullContact = require('cordova/plugin/contacts').create(result);
-              successCB(convertIn(fullContact));
-          }
-      }
-      else {
-          // no Entry object returned
-          fail(ContactError.UNKNOWN_ERROR);
-      }
-  };
+        if (result) {
+            if (successCB) {
+                var fullContact = require('cordova/plugin/contacts').create(result);
+                successCB(convertIn(fullContact));
+            }
+        }
+        else {
+            // no Entry object returned
+            fail(ContactError.UNKNOWN_ERROR);
+        }
+    };
     var dupContact = convertOut(utils.clone(this));
     exec(success, fail, "Contacts", "save", [dupContact]);
 };