commit 0add2d07e6a5a1445a5a677c3b64f046f0810738
parent c8d5e0b8c6e27f27946db7c5fad86dd2825046b1
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 6 Jul 2011 07:39:49 +0000
Move Zotero.varDump to Zotero.Utilities
Diffstat:
4 files changed, 48 insertions(+), 50 deletions(-)
diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js
@@ -345,7 +345,7 @@ Zotero.DBConnection.prototype.getStatement = function (sql, params, checkParams)
}
else {
var msg = 'Invalid bound parameter ' + params[i]
- + ' in ' + Zotero.varDump(params)
+ + ' in ' + Zotero.Utilities.varDump(params)
+ ' [QUERY: ' + sql + ']';
Zotero.debug(msg);
throw(msg);
diff --git a/chrome/content/zotero/xpcom/debug.js b/chrome/content/zotero/xpcom/debug.js
@@ -52,7 +52,7 @@ Zotero.Debug = new function () {
}
if (typeof message != 'string') {
- message = Zotero.varDump(message);
+ message = Zotero.Utilities.varDump(message);
}
if (!level) {
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -737,8 +737,8 @@ Zotero.Utilities = {
},
/**
- * Generate a random string of length 'len' (defaults to 8)
- **/
+ * Generate a random string of length 'len' (defaults to 8)
+ **/
"randomString":function(len, chars) {
if (!chars) {
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
@@ -752,6 +752,50 @@ Zotero.Utilities = {
randomstring += chars.substring(rnum,rnum+1);
}
return randomstring;
+ },
+
+ /**
+ * PHP var_dump equivalent for JS
+ *
+ * Adapted from http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html
+ */
+ "varDump":function(arr,level) {
+ var dumped_text = "";
+ if (!level){
+ level = 0;
+ }
+
+ // The padding given at the beginning of the line.
+ var level_padding = "";
+ for (var j=0;j<level+1;j++){
+ level_padding += " ";
+ }
+
+ if (typeof(arr) == 'object') { // Array/Hashes/Objects
+ for (var item in arr) {
+ var value = arr[item];
+
+ if (typeof(value) == 'object') { // If it is an array,
+ dumped_text += level_padding + "'" + item + "' ...\n";
+ dumped_text += arguments.callee(value,level+1);
+ }
+ else {
+ if (typeof value == 'function'){
+ dumped_text += level_padding + "'" + item + "' => function(...){...} \n";
+ }
+ else if (typeof value == 'number') {
+ dumped_text += level_padding + "'" + item + "' => " + value + "\n";
+ }
+ else {
+ dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
+ }
+ }
+ }
+ }
+ else { // Stings/Chars/Numbers etc.
+ dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
+ }
+ return dumped_text;
}
}
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -73,7 +73,6 @@ if(appInfo.platformVersion[0] >= 2) {
this.logError = logError;
this.getErrors = getErrors;
this.getSystemInfo = getSystemInfo;
- this.varDump = varDump;
this.safeDebug = safeDebug;
this.getString = getString;
this.localeJoin = localeJoin;
@@ -1284,51 +1283,6 @@ if(appInfo.platformVersion[0] >= 2) {
}
- /**
- * PHP var_dump equivalent for JS
- *
- * Adapted from http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html
- */
- function varDump(arr,level) {
- var dumped_text = "";
- if (!level){
- level = 0;
- }
-
- // The padding given at the beginning of the line.
- var level_padding = "";
- for (var j=0;j<level+1;j++){
- level_padding += " ";
- }
-
- if (typeof(arr) == 'object') { // Array/Hashes/Objects
- for (var item in arr) {
- var value = arr[item];
-
- if (typeof(value) == 'object') { // If it is an array,
- dumped_text += level_padding + "'" + item + "' ...\n";
- dumped_text += arguments.callee(value,level+1);
- }
- else {
- if (typeof value == 'function'){
- dumped_text += level_padding + "'" + item + "' => function(...){...} \n";
- }
- else if (typeof value == 'number') {
- dumped_text += level_padding + "'" + item + "' => " + value + "\n";
- }
- else {
- dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
- }
- }
- }
- }
- else { // Stings/Chars/Numbers etc.
- dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
- }
- return dumped_text;
- }
-
-
function safeDebug(obj){
for (var i in obj){
try {