home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.tcs3.com
/
ftp.tcs3.com.tar
/
ftp.tcs3.com
/
DRIVERS
/
Audio
/
Office2010
/
ProPlus.WW
/
ProPsWW.cab
/
HIERARCHY.JS
< prev
next >
Wrap
Text File
|
2007-02-04
|
6KB
|
176 lines
function collapseExpandRow(i_strTaskID)
{
var objTask = document.getElementById(i_strTaskID);
var objImage = document.getElementById(i_strTaskID + "Image");
var strChildStatus = objTask.getAttribute("childstatus");
if (strChildStatus != null && strChildStatus == "hidden")
{
objTask.setAttribute("childstatus", "visible");
objImage.src = "minus.gif";
expandRow(i_strTaskID);
}
else
{
objTask.setAttribute("childstatus", "hidden");
objImage.src = "plus.gif";
collapseRow(i_strTaskID);
}
}
function collapseRow(i_strTaskID)
{
var objTask = document.getElementById(i_strTaskID);
var intDepth = getTaskDepth(objTask);
// Search for children of this row.
if (intDepth != null)
{
objTask = objTask.nextSibling;
var intSiblingDepth = getTaskDepth(objTask);
// Find every descendant of the task and hide it.
while (objTask != null && intSiblingDepth != null && intSiblingDepth > intDepth)
{
objTask.style.display = "none";
objTask = objTask.nextSibling;
intSiblingDepth = getTaskDepth(objTask);
}
}
}
function expandRow(i_strTaskID)
{
var objTask = document.getElementById(i_strTaskID);
var intDepth = getTaskDepth(objTask);
// Search for children of this row.
if (intDepth != null)
{
objTask = objTask.nextSibling;
var intSiblingDepth = getTaskDepth(objTask);
while (objTask != null && intSiblingDepth != null && intSiblingDepth > intDepth)
{
objTask.style.display = "block";
// Search for children of this row if they are visible.
var strChildStatus = objTask.getAttribute("childstatus");
if (strChildStatus == null || (strChildStatus != null && strChildStatus == "hidden"))
objTask = skipSibling(objTask, intSiblingDepth, intDepth);
else
objTask = objTask.nextSibling;
// Get the depth of the current task.
intSiblingDepth = getTaskDepth(objTask);
}
}
}
function skipSibling(i_objTask, i_intSiblingDepth, i_intDepth)
{
i_objTask = i_objTask.nextSibling;
var intCurrentDepth = getTaskDepth(i_objTask);
while (i_objTask != null && intCurrentDepth != null && intCurrentDepth > i_intSiblingDepth)
{
i_objTask = i_objTask.nextSibling;
intCurrentDepth = getTaskDepth(i_objTask);
}
// Return the new task so the search can continue.
if (i_objTask != null)
return i_objTask;
}
function getTaskDepth(i_objTask)
{
if (i_objTask != null)
{
var intTaskDepth = Number(i_objTask.getAttribute("depth"));
if (!isNaN(intTaskDepth))
return intTaskDepth;
}
return null;
}
function highlightRow(i_objRow)
{
var arrRows = document.getElementsByTagName("TR");
for (var i = 0; i < arrRows.length; i++)
{
arrRows[i].style.backgroundColor = "";
}
i_objRow.style.backgroundColor = "yellow";
// Build the preview table for the selected row.
var strParentId = i_objRow.getAttribute("parentid");
var objParentRow = document.getElementById(strParentId + "_Subject");
if (objParentRow != null)
document.getElementById("previewParentSubject").innerHTML = objParentRow.innerText;
else
document.getElementById("previewParentSubject").innerHTML = " ";
var strRowId = i_objRow.id;
var arrCells = i_objRow.getElementsByTagName("TD");
for (var i = 0; i < arrCells.length; i++)
{
var strCellId = arrCells[i].id;
var strCellText = trimEnds(arrCells[i].innerText);
// Replace brackets since it will be interpreted as an HTML tag otherwise.
strCellText = strCellText.replace(/\&/g, "\&");
strCellText = strCellText.replace(/</g, "\<");
strCellText = strCellText.replace(/>/g, "\>");
if (strCellText == "")
strCellText = "N/A";
if (strCellId == strRowId + "_Subject")
document.getElementById("previewSubject").innerHTML = strCellText;
else if (strCellId == strRowId + "_AssignedTo")
{
// Adjust the Assigned To label for project record.
var strProjectTaskId = i_objRow.getAttribute("ProjectTaskId");
if (strProjectTaskId == "")
document.getElementById("previewAssignedToLabel").innerText = "Assigned To:";
else
document.getElementById("previewAssignedToLabel").innerText = "Project Leader:";
var strProjectTaskLeader = i_objRow.getAttribute("ProjectTaskLeader");
if (strProjectTaskLeader == "")
document.getElementById("previewAssignedTo").innerHTML = strCellText;
else
{
strProjectTaskLeader = strProjectTaskLeader.replace(/\&/g, "\&");
document.getElementById("previewAssignedTo").innerHTML = strProjectTaskLeader;
}
}
else if (strCellId == strRowId + "_StartDate")
document.getElementById("previewStartDate").innerHTML = strCellText;
else if (strCellId == strRowId + "_DueDate")
document.getElementById("previewDueDate").innerHTML = strCellText;
else if (strCellId == strRowId + "_Status")
document.getElementById("previewStatus").innerHTML = strCellText;
else if (strCellId == strRowId + "_Priority")
document.getElementById("previewPriority").innerHTML = strCellText;
else if (strCellId == strRowId + "_Description")
document.getElementById("previewDescription").innerHTML = strCellText;
}
/*
var strDescription = i_objRow.getAttribute("description");
if (strDescription != null && strDescription != "")
document.getElementById("previewDescription").innerHTML = strDescription;
*/
}
function highlightProjectTask()
{
var arrRows = document.getElementsByTagName("TR");
for (var i = 0; i < arrRows.length; i++)
{
var objRow = arrRows[i];
if (objRow.getAttribute("ProjectTaskID") != null && objRow.getAttribute("ProjectTaskLeader"))
{
highlightRow(objRow);
break;
}
}
}
function trimEnds(i_String)
{
i_String = i_String.replace(/^(\s)*/, "");
i_String = i_String.replace(/(\s)*$/, "");
return i_String;
}