/** 平台用post func
 *  CSWEB uses post func
 *
 *	fid :Dom element/id or class string
 *	pary:Set object/json string(Optional)
 *	{
 *		ckary:check tag array
 *		inary:check input type value array
 *		tary :search tag array
 *		clas :get value attribute name string
 *		vary :output value attribute name array
 *		mout :single output array type flag
 *		objt :output string or object flag
 *	}
 */
function csweb_htmltojson(fid, pary){
	var ckary = ['input','select','textarea'],
		inary = ['color','date','datetime-local','hidden','month',
				 'number','password','range','search','text',
				 'time'],
		tary = ['input','select','textarea'],
		vary = ['val'],
		clas = 'name',mout = 0,objt = 0,data = [],etype = '',tname = '',
		itype = '',atype = false,nm = '',val = '',aname = '',o = {};
	if(isck_OBJECT(pary) || isck_JSON(pary)){
		if(isck_JSON(pary)) pary = JSON.parse(pary);
		if(isck_ARRAY(pary.ckary)) ckary = pary.ckary;
		if(isck_ARRAY(pary.inary)) inary = pary.inary;
		if(isck_ARRAY(pary.tary)) tary = pary.tary;
		if(isck_ARRAY(pary.vary)) vary = pary.vary;
		if(isck_STRING(pary.clas,'Y')) clas = pary.clas;
		mout = (pary.mout) ? 1 : 0;objt = (pary.objt) ? 1 : 0;
	}
	if(isck_STRING(fid,'Y')) fid = document.querySelectorAll(fid);
	if(isck_OBJECT(fid)){
		for(var i = 0; i < fid.length; i++){
			data = fid[i].querySelectorAll(tary.join(','));
			if(!isck_OBJECT(data)) continue;
			for(var j = 0; j < data.length; j++){
				etype = (data[j].tagName) ? data[j].tagName : '';
				tname = ((clas) && 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(isck_STRING(data[j].value)){
							val = data[j].value;aname = tname;
						}
					}else if(vary[k] == 'html'){
						if(isck_STRING(data[j].innerHTML)){
							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(isck_STRING(data[j].getAttribute(nm))){
							val = data[j].getAttribute(nm);aname = (nm == 'val' || nm == 'html') ? tname+'_attr'+nm : tname+'_'+nm;
						}
					}
					if(aname == '') continue;
					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));
}