4 lines
889 B
JavaScript
4 lines
889 B
JavaScript
function FormDeflater(b,c,a){for(var d=0;d<c.length;d++)c[d]=c[d].toLowerCase();for(d=0;d<a.length;d++)a[d]=a[d].toLowerCase();this.container=b;this.tags=c;this.attr=a}
|
|
FormDeflater.prototype={container:this.container,tags:this.tags,attr:this.attr,deflate:function(){for(var b=this.getChildren(this.container),b=this.filterElements(b),c={},a=0;a<b.length;a++)for(var d=0;d<this.attr.length;d++){var e=b[a].getAttribute(this.attr[d]);if(null!==e&&0<e.length){c.hasOwnProperty(e)?c[e]instanceof Array?c[e].push(b[a].value):c[e]=[c[e],b[a].value]:c[e]=b[a].value;break}}return c},getChildren:function(b){if(!(b instanceof Element))return[];for(var c=b=[].slice.call(b.children),
|
|
a=0;a<b.length;a++)c=c.concat([].slice.call(this.getChildren(b[a])));return c},filterElements:function(b){for(var c=[],a=0;a<b.length;a++)-1<this.tags.indexOf(b[a].tagName.toLowerCase())&&c.push(b[a]);return c}};
|