You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/01/03 19:57:12 UTC
[50/50] git commit: Remove PhoneGap.stringify,
replace with JSON.stringify
Remove PhoneGap.stringify, replace with JSON.stringify
Since we don't support Android 1.5/1.6 anymore we don't need to check to see if JSON.stringify is around as it is included in Android 2.1+. By removing this check for JSON.stringify we remove two conditional checks on each call to PhoneGap.exec.
As well we get rid of 60 lines of code which are currently bloating phonegap.js.base.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/cf9848bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/cf9848bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/cf9848bd
Branch: refs/heads/master
Commit: cf9848bd59c726a950ae9906b92e2515e578b4d3
Parents: 7ad3f76
Author: macdonst <si...@gmail.com>
Authored: Fri Nov 4 04:08:18 2011 +0800
Committer: macdonst <si...@gmail.com>
Committed: Fri Nov 4 04:30:46 2011 +0800
----------------------------------------------------------------------
framework/assets/js/phonegap.js.base | 61 +----------------------------
1 files changed, 1 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/cf9848bd/framework/assets/js/phonegap.js.base
----------------------------------------------------------------------
diff --git a/framework/assets/js/phonegap.js.base b/framework/assets/js/phonegap.js.base
index b1ab0a0..2e7110a 100755
--- a/framework/assets/js/phonegap.js.base
+++ b/framework/assets/js/phonegap.js.base
@@ -537,65 +537,6 @@ PhoneGap.fireWindowEvent = function(type, data) {
};
/**
- * If JSON not included, use our own stringify. (Android 1.6)
- * The restriction on ours is that it must be an array of simple types.
- *
- * @param args
- * @return {String}
- */
-PhoneGap.stringify = function(args) {
- if (typeof JSON === "undefined") {
- var s = "[";
- var i, type, start, name, nameType, a;
- for (i = 0; i < args.length; i++) {
- if (args[i] !== null) {
- if (i > 0) {
- s = s + ",";
- }
- type = typeof args[i];
- if ((type === "number") || (type === "boolean")) {
- s = s + args[i];
- } else if (args[i] instanceof Array) {
- s = s + "[" + args[i] + "]";
- } else if (args[i] instanceof Object) {
- start = true;
- s = s + '{';
- for (name in args[i]) {
- if (args[i][name] !== null) {
- if (!start) {
- s = s + ',';
- }
- s = s + '"' + name + '":';
- nameType = typeof args[i][name];
- if ((nameType === "number") || (nameType === "boolean")) {
- s = s + args[i][name];
- } else if ((typeof args[i][name]) === 'function') {
- // don't copy the functions
- s = s + '""';
- } else if (args[i][name] instanceof Object) {
- s = s + PhoneGap.stringify(args[i][name]);
- } else {
- s = s + '"' + args[i][name] + '"';
- }
- start = false;
- }
- }
- s = s + '}';
- } else {
- a = args[i].replace(/\\/g, '\\\\');
- a = a.replace(/"/g, '\\"');
- s = s + '"' + a + '"';
- }
- }
- }
- s = s + "]";
- return s;
- } else {
- return JSON.stringify(args);
- }
-};
-
-/**
* Does a deep clone of the object.
*
* @param obj
@@ -673,7 +614,7 @@ PhoneGap.exec = function(success, fail, service, action, args) {
PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
}
- var r = prompt(PhoneGap.stringify(args), "gap:"+PhoneGap.stringify([service, action, callbackId, true]));
+ var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
// If a result was returned
if (r.length > 0) {