util.js 859 B

123456789101112131415161718192021222324252627
  1. if ((!window.console) || (! /__debug__$/i.test(document.location.href))) {
  2. // non-debug mode, an empty function
  3. window.console = window.console || {};
  4. window.console.log = function(message) {};
  5. }
  6. function dirObj(obj, depth, parent) {
  7. var msg = "";
  8. var val = "";
  9. if (! depth) { depth=2; }
  10. if (! parent) { parent= ""; }
  11. // Print the properties of the passed-in object
  12. for (var i in obj) {
  13. if ((depth > 1) && (typeof obj[i] == "object")) {
  14. // Recurse attributes that are objects
  15. msg += dirObj(obj[i], depth-1, parent + "." + i);
  16. } else {
  17. val = new String(obj[i]).replace("\n", " ");
  18. if (val.length > 30) {
  19. val = val.substr(0,30) + "...";
  20. }
  21. msg += parent + "." + i + ": " + val + "\n";
  22. }
  23. }
  24. return msg;
  25. }