var inList = new Array(); var outList = new Array(); var leftD = 20; function cadd(ins) { inList[inList.length] = ins; } function drawCommentList() { var rootList = getListByParentId('0'); fillChild(rootList, 0); var outS = new String(); for(var i = 0; i < outList.length; i++) { var cid = outList[i].split(",")[0]; var div = document.getElementById(cid); var divC = document.getElementById("" + cid + "_1");//div.childNodes[0]; // alert(divC); divC.style.margin = "0px 0px 0px " + leftD * outList[i].split(",")[2] + "px"; // divC.style.marginLeft = "" + leftD * outList[i].split(",")[2] + "px"; // .style.margin-left = leftD * outList[i].split(",")[2] + "px"; outS = outS + div.innerHTML; } // alert(outS); document.getElementById("commentJs").innerHTML = outS; //alert(rootList.length); } function fillChild(rootList, cc) { for(var i = 0; i < rootList.length; i++) { oadd(inList[rootList[i]] + "," + cc); var cpid = inList[rootList[i]].split(",")[0]; var childList = getListByParentId(cpid); fillChild(childList, cc + 1); } } function oadd(ins) { outList[outList.length] = ins; } function getListByParentId(pid) { var ret = new Array(); for(var i = 0; i < inList.length; i++ ) { var cpid = inList[i].split(",")[1]; if( cpid == pid ) { ret[ret.length] = i; } } return ret; }