/* 平台用post func */
function csweb_htmltojson(fid, pary){
	var o = {}, ckary = ['input','select','textarea'],
		inary = ['color','date','datetime-local','hidden','month',
				 'number','password','range','search','text',
				 'time'],
		tary = ['input','select','textarea'], clas = 'name', vary = ['val'],
		mout = 0, objt = 0, data = [], etype = '', tname = '', itype = '',
		atype = false, nm = '', val = '', aname = '';
	if(pary){
		if (pary.ckary) ckary = pary.ckary;
		if (pary.inary) inary = pary.inary;
		if (pary.tary) tary = pary.tary;
		if (pary.clas) clas = pary.clas;
		if (pary.vary) vary = pary.vary;
		if (pary.mout) mout = 1;
		if (pary.objt) objt = 1;
		if (typeof ckary == 'string') ckary = [ckary];
		if (typeof inary == 'string') inary = [inary];
		if (typeof tary == 'string') tary = [tary];
		if (typeof vary == 'string') vary = [vary];
	}
	if(typeof fid == 'string'){
		fid = document.querySelectorAll(((fid.substr(0,1) != '#' && fid.substr(0,1) != '.') ? '#'+fid : fid));
	}
	if(fid.length > 0 && tary.length > 0 && vary.length > 0){
		for(var i = 0; i < fid.length; i++){
			data = fid[i].querySelectorAll(tary.join(','));
			//console.log(data);
			for(var j = 0; j < data.length; j++){
				etype = (data[j].tagName) ? data[j].tagName : '';
				tname = (data[j].getAttribute(clas)) ? data[j].getAttribute(clas).replace('[]','') : '';
				itype = (data[j].type) ? data[j].type : '';
				if (etype == '' || tname == '' || (etype == 'input' && inary.indexOf(itype) == -1)) continue;
				atype = ((mout) && data[j].getAttribute(clas).substr(-2) == '[]') ? true : false;
				for(var k = 0; k < vary.length; k++){
					val = '';aname = '';
					if(vary[k] == 'val'){
						if((data[j].value) || data[j].value == '' || data[j].value == 0){
							val = data[j].value;aname = tname;
						}
					}else if(vary[k] == 'html'){
						if((data[j].innerHTML) || data[j].innerHTML == '' || data[j].innerHTML == 0){
							val = data[j].innerHTML;aname = (ckary.indexOf(etype) == -1) ? tname+'_'+vary[k] : '';
						}
					}else if(vary[k].substr(0,4) == 'attr' && vary[k].substr(5,4) != 'attr' && (vary[k].substr(5))){
						nm = vary[k].substr(5);
						if((data[j].getAttribute(nm)) || data[j].getAttribute(nm) == '' || data[j].getAttribute(nm) == 0){
							val = data[j].getAttribute(nm);aname = (nm == 'val' || nm == 'html') ? tname+'_attr'+nm : tname+'_'+nm;
						}
					}
					if(aname != ''){
						if((o[aname]) || o[aname] == '' || o[aname] == 0){
							if(!o[aname].push) o[aname] = [o[aname]];
							o[aname].push(val || '');
						}else{
							if(atype){
								o[aname] = [];
								o[aname].push(val || '');
							}else o[aname] = val || '';
						}
					}
				}
			}
		}
	}
	return ((objt) ? o : JSON.stringify(o));
}