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/site@349 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-16 07:12:18 +00:00
parent d0dfd8657c
commit 331e235e77

View File

@@ -191,7 +191,7 @@ function datepickerEOM(fromid, id) {
// I'm not keen on redesigning it at the moment. So, here // I'm not keen on redesigning it at the moment. So, here
// is a serialize implementation I found on the web. // is a serialize implementation I found on the web.
function serialize( mixed_value ) { function serialize( mixed_value, depth ) {
// http://kevin.vanzonneveld.net // http://kevin.vanzonneveld.net
// + original by: Arpad Ray (mailto:arpad@php.net) // + original by: Arpad Ray (mailto:arpad@php.net)
// + improved by: Dino // + 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";}' // * 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'}); // * 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";}' // * 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('<P>');
// $("#debug").append(depth+"serialize()<BR>\n");
// if (depth.length > 80) {
// $("#debug").append(depth+"OVERFLOW<BR>\n");
// return 'ABORTED';
// }
var _getType = function( inp ) { var _getType = function( inp ) {
var type = typeof inp, match; var type = typeof inp, match;
var key; var key;
@@ -233,6 +245,8 @@ function serialize( mixed_value ) {
}; };
var type = _getType(mixed_value); var type = _getType(mixed_value);
var val, ktype = ''; var val, ktype = '';
// $("#debug").append(depth+"&nbsp;&nbsp;- type: "+type+"<BR>\n");
switch (type) { switch (type) {
case "function": case "function":
@@ -269,13 +283,16 @@ function serialize( mixed_value ) {
var key; var key;
for (key in mixed_value) { for (key in mixed_value) {
ktype = _getType(mixed_value[key]); ktype = _getType(mixed_value[key]);
// $("#debug").append(depth+"&nbsp;&nbsp;&nbsp;&nbsp;- key["+count+"] type: "+type+"<BR>\n");
if (ktype == "function") { if (ktype == "function") {
continue; continue;
} }
okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key); okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key);
vals += serialize(okey) + // $("#debug").append(depth+"&nbsp;&nbsp;&nbsp;&nbsp;- okey: "+okey+"<BR>\n");
serialize(mixed_value[key]); // $("#debug").append(depth+"&nbsp;&nbsp;&nbsp;&nbsp;- mixed[key]: "+mixed_value[key]+"<BR>\n");
vals += serialize(okey, depth+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;') +
serialize(mixed_value[key], depth+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
count++; count++;
} }
val += ":" + count + ":{" + vals + "}"; val += ":" + count + ":{" + vals + "}";
@@ -284,6 +301,7 @@ function serialize( mixed_value ) {
if (type != "object" && type != "array") { if (type != "object" && type != "array") {
val += ";"; val += ";";
} }
// $("#debug").append(depth+"&nbsp;&nbsp;- val: "+val+"<BR>\n");
return val; return val;
} }