Develop and Download Open Source Software

Browse Subversion Repository

Diff of /js/common.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by berupon, Tue Dec 22 15:50:45 2009 UTC revision 15 by berupon, Tue Dec 22 20:55:39 2009 UTC
# Line 595  function distributeElements(elements, ke Line 595  function distributeElements(elements, ke
595          return arr;          return arr;
596  }  }
597    
598    // http://bytes.com/topic/javascript/answers/715567-deep-cloning-object
599    function clone_obj(obj) {
600            var c = obj instanceof Array ? [] : {};
601            for (var i in obj) {
602                    var prop = obj[i];
603                    if (typeof prop == 'object') {
604                            if (prop instanceof Array) {
605                                    c[i] = [];
606                                    for (var j = 0; j < prop.length; j++) {
607                                            if (typeof prop[j] != 'object') {
608                                                    c[i].push(prop[j]);
609                                            } else {
610                                                    c[i].push(clone_obj(prop[j]));
611                                            }
612                                    }
613                            }else {
614                                    c[i] = clone_obj(prop);
615                            }
616                    }else {
617                            c[i] = prop;
618                    }
619            }
620            return c;
621    }
622    

Legend:
Removed from v.14  
changed lines
  Added in v.15

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26