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:
@@ -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('<P>');
|
||||
|
||||
// $("#debug").append(depth+"serialize()<BR>\n");
|
||||
|
||||
// if (depth.length > 80) {
|
||||
// $("#debug").append(depth+"OVERFLOW<BR>\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+"<BR>\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+"<BR>\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+"<BR>\n");
|
||||
// $("#debug").append(depth+" - mixed[key]: "+mixed_value[key]+"<BR>\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+"<BR>\n");
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user