From b2ab1349969fc701f495ccc6d0b8d46bc421cd4d Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 16 Jul 2009 07:12:18 +0000 Subject: [PATCH] Added debugging to the serialize function. I don't really want to keep it, but I don't want to lose it either. At least one check in before I clean it up again (if I do). git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@349 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/webroot/js/pmgr.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/site/webroot/js/pmgr.js b/site/webroot/js/pmgr.js index b9b96be..b9ce8a0 100644 --- a/site/webroot/js/pmgr.js +++ b/site/webroot/js/pmgr.js @@ -191,7 +191,7 @@ function datepickerEOM(fromid, id) { // I'm not keen on redesigning it at the moment. So, here // is a serialize implementation I found on the web. -function serialize( mixed_value ) { +function serialize( mixed_value, depth ) { // http://kevin.vanzonneveld.net // + original by: Arpad Ray (mailto:arpad@php.net) // + improved by: Dino @@ -205,7 +205,19 @@ function serialize( mixed_value ) { // * returns 1: 'a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}' // * example 2: serialize({firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'}); // * returns 2: 'a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}' - +// if (depth == null) +// depth = ''; + +// if (depth == '') +// $("#debug").html('

'); + +// $("#debug").append(depth+"serialize()
\n"); + +// if (depth.length > 80) { +// $("#debug").append(depth+"OVERFLOW
\n"); +// return 'ABORTED'; +// } + var _getType = function( inp ) { var type = typeof inp, match; var key; @@ -233,6 +245,8 @@ function serialize( mixed_value ) { }; var type = _getType(mixed_value); var val, ktype = ''; + +// $("#debug").append(depth+"  - type: "+type+"
\n"); switch (type) { case "function": @@ -269,13 +283,16 @@ function serialize( mixed_value ) { var key; for (key in mixed_value) { ktype = _getType(mixed_value[key]); +// $("#debug").append(depth+"    - key["+count+"] type: "+type+"
\n"); if (ktype == "function") { continue; } okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key); - vals += serialize(okey) + - serialize(mixed_value[key]); +// $("#debug").append(depth+"    - okey: "+okey+"
\n"); +// $("#debug").append(depth+"    - mixed[key]: "+mixed_value[key]+"
\n"); + vals += serialize(okey, depth+'      ') + + serialize(mixed_value[key], depth+'      '); count++; } val += ":" + count + ":{" + vals + "}"; @@ -284,6 +301,7 @@ function serialize( mixed_value ) { if (type != "object" && type != "array") { val += ";"; } +// $("#debug").append(depth+"  - val: "+val+"
\n"); return val; }