📄 deeptree.js
字号:
{
if( null == objLI_Current ) return;
if( null == objLI_Current ) objLI_Current = GetHtmlElement( element , "div" );
var objLI_New;
objLI_New = GetPreviousSibling(objLI_Current);
if (objLI_New != null)
{
SelectNode(objLI_New, false, true);
}
else
{
objLI_New = GetParent(objLI_Current);
if (objLI_New != null)
{
SelectNode(objLI_New, false, true);
}
}
}
//-----------------------------------------------
// MoveLeft()
//-----------------------------------------------
function MoveLeft()
{
var objLI_New;
if( null == objLI_Current ) objLI_Current = GetHtmlElement( element , "div" );
if (objLI_Current.state == "shown")
{
CollapseNode(objLI_Current);
}
else
{
objLI_New = GetParent(objLI_Current);
if (objLI_New != null)
{
SelectNode(objLI_New, false, true);
}
}
}
//-----------------------------------------------
// MoveUp()
//-----------------------------------------------
function MoveUp()
{
var objLI_New;
if( null == objLI_Current ) objLI_Current = GetHtmlElement( element , "div" );
objLI_New = GetPreviousSibling(objLI_Current);
if (objLI_New != null)
{
while (objLI_New.state == "shown")
{
objLI_New = GetLastChild(objLI_New);
}
SelectNode(objLI_New, false, true);
}
else
{
objLI_New = GetParent(objLI_Current);
if (objLI_New != null)
{
SelectNode(objLI_New, false, true);
}
}
}
//-----------------------------------------------
// MoveRight()
//-----------------------------------------------
function MoveRight()
{
var objLI_New;
if( null == objLI_Current ) objLI_Current = GetHtmlElement( element , "div" );
if( objLI_Current.state == "shown")
{
objLI_New = GetFirstChild(objLI_Current);
if (objLI_New != null)
{
SelectNode(objLI_New, false, true);
}
}
else if( objLI_Current.type != "leaf" )
{
ExpandNode(objLI_Current);
}
}
//-----------------------------------------------
// MoveDown()
//-----------------------------------------------
function MoveDown()
{
var objLI_New;
var objLI_Temp;
if( null == objLI_Current ) objLI_Current = GetHtmlElement( element , "div" );
if (objLI_Current.state == "shown")
{
objLI_New = GetFirstChild(objLI_Current);
SelectNode(objLI_New, false, true);
}
else
{
objLI_Temp = objLI_Current;
objLI_New = GetNextSibling(objLI_Temp);
while (objLI_New == null)
{
objLI_Temp = GetParent(objLI_Temp);
if (objLI_Temp == null)
{
objLI_New = objLI_Current;
}
else
{
objLI_New = GetNextSibling(objLI_Temp);
}
}
SelectNode(objLI_New, false, true);
}
}
//-----------------------------------------------
// Sync(xml)
//-----------------------------------------------
function SyncAsync( oSync )
{
if( null != oSync.oLi )
{
oSync.oLastLi = oSync.oLi;
}
if( null == oSync.oContextList ) return false;
var oElementId = oSync.oContextList.item( oSync.iCurrentIdx ).getAttribute( "id" );
var oEl = window.document.all( oElementId );
if( !oSync.bBadIds && null != oEl && "object" == typeof( oEl ) )
{
oSync.oLi = oEl.parentElement;
}
else
{
oSync.bBadIds = true;
var sTitle = oSync.oContextList.item( oSync.iCurrentIdx ).getAttribute( "label" );
oEl = GetNodeFromTitle( sTitle , oSync.oLastLi );
if( null != oEl )
{
oSync.oLi = oEl.parentElement;
}
}
oSync.iCurrentIdx++;
if( oSync.iCurrentIdx == oSync.oContextList.length )
{
ExpandNode( oSync.oLi , null );
SelectNode( oSync.oLi , true, true );
}
else
{
ExpandNode( oSync.oLi , oSync );
}
if( oSync.oLi == null ) return false;
return true;
}
function SyncObject( oContextList )
{
this.oContextList = oContextList;
this.oLi = null;
this.oLastLi = null;
this.bBadIds = false;
this.iCurrentIdx = 0;
}
function Sync( sNodeId )
{
try
{
if( top.content.document.body.readyState != "complete" )
{
return;
}
var oContextXml = top.content.xmlPageContext;
oContextXml = oContextXml.selectNodes( "//item[@id]" );
var oSync = new SyncObject( oContextXml );
if( !SyncAsync( oSync ) )
{
m_bSyncFailed = true;
}
}
catch(e)
{
m_bSyncFailed = true;
}
}
//-------------------------------------------------------------------------------------------------
// PRIVATE METHODS
//-------------------------------------------------------------------------------------------------
function GetNodeFromTitle( sTitle , oParentEl )
{
var oList = null;
var oNode = null;
var oTmpNode = null;
if( oParentEl == null )
{
oList = element.children;
}
else
{
var oList = GetChildren( oParentEl );
}
for( var i = 0; i < oList.length; i++ )
{
oTmpNode = GetHtmlElement( oList[i] , "SPAN" , "label" )
if( null != oTmpNode && "object" == typeof( oTmpNode ) && oTmpNode.title == sTitle )
{
oNode = oTmpNode;
break;
}
}
return oNode;
}
//-----------------------------------------------
// ToggleNode(objLI)
//-----------------------------------------------
function ToggleNode(objLI)
{
if (objLI.type == "parent")
{
if (objLI.state == "shown")
{
//如果这个结点下的内容已经被加载,就不用再加载一次了。
CollapseNode(objLI);
}
else
{
ExpandNode(objLI);
}
}
}
//-----------------------------------------------
// CollapseNode(objLI)
//-----------------------------------------------
function CollapseNode(objLI)
{
var i = 0;
var objUL;
var objIMG;
objUL = GetHtmlElement(objLI,"DIV","container");
if (objUL != null)
{
objIMG = GetHtmlElement(objLI,"SPAN","img");
if (objUL != null)
{
objLI.state = "hidden";
objUL.className = "hide";
objIMG.innerHTML = "<span class='clsCollapse'>+</span>";
if (IsChild(objLI_Current, objLI) == true)
{
SelectNode(objLI, false, false);
}
}
}
}
//-----------------------------------------------
// ExpandNode(objLI)
// 加载这个节点,需要读取xml 文件
//-----------------------------------------------
function ExpandNode( objLI , oSync )
{
var i = 0;
var objUL;
var objIMG;
var objSPAN;
objUL = GetHtmlElement(objLI,"DIV","container");
if (objUL != null)
{
objIMG = GetHtmlElement(objLI,"SPAN","img");
if (objIMG != null)
{
objSPAN = GetHtmlElement(objLI,"SPAN","label");
objUL.className = "shown";
objIMG.innerHTML = "<span class='clsExpand'>-</span>";
//objIMG.src = "/library/shared/deeptree/graphics/expand.gif";
objLI.state = "shown";
return LoadChildren( objLI , oSync );
}
}
}
//-----------------------------------------------
// SelectNode(objLI, bSuppressLink)
//-----------------------------------------------
function SelectNode( objLI, bSupressLink, bForceIntoView )
{
var objA;
var objSPAN;
if( null == objLI ) objLI = GetHtmlElement( element , "div" );
if( objLI.type == "none" )
{
objLI_Parent = GetParent( objLI );
objLI_Next = GetNextSibling( objLI_Parent );
}
if( bSupressLink != true )
{
//这个结点需要连接到的地方定义
LoadNodeContent(objLI);
}
//加亮结点
HighlightNode(objLI);
ExpandAncestors( objLI );
ScrollIntoView( objLI, bForceIntoView );
UpdateMessages( objLI );
try
{
if( "object" == typeof( top.contentbar ) && "object" == typeof( top.contentbar.document.all("showtoc") ) )
{
//top.contentbar.document.all("showtoc").style.display = "none";
}
}
catch(e)
{
}
}
function UpdateMessages( objLI )
{
objSPAN = GetHtmlElement(objLI,"SPAN","label");
if( null != objSPAN )
{
window.defaultStatus = objSPAN.title;
// top.document.title = objSPAN.title;
}
}
// 当前焦点滚动到中间位置。
function ScrollIntoView( objLI, bScroll )
{
//var iY = window.document.body.scrollTop;
//var iX = window.document.body.scrollLeft;
//var bScrollY = ( objLI.offsetTop < iY || objLI.offsetTop + 19 > iY + window.document.body.clientHeight );
//var bScrollX = false;
//( objLI.offsetLeft < iX || objLI.offsetLeft + objLI.offsetWidth/2 > iX + window.document.body.clientWidth );
if( bScroll )
{
//var iY = !( bScrollY || bScroll ) ? iY :
//var iX = !( bScrollX || bScroll ) ? iX :
var iY = objLI.offsetTop - window.document.body.clientHeight/2;
var iX = objLI.offsetLeft - 15;
window.scrollTo( iX , iY );
}
return;
}
function ExpandAncestors( objLI )
{
while( objLI = GetParent( objLI ) )
{
if( objLI.state != "shown" ) ExpandNode( objLI );
}
}
//加亮当前选择的节点
function HighlightNode(objLI)
{
var i = 0;
var objSPAN;
var objSPAN_Current;
objSPAN = GetHtmlElement(objLI,"SPAN","label");
if (objSPAN != null)
{
if (objSPAN.classType != "clsUnavailable")
{
objSPAN.className = "clsCurrentHasFocus";
objSPAN.classType = "clsCurrentHasFocus";
if (objLI != objLI_Current)
{
if (objLI_Current != "")
{
objSPAN_Current = GetHtmlElement(objLI_Current,"SPAN","label");
if (objSPAN_Current != null)
{
objSPAN_Current.className = "";
objSPAN_Current.classType = "";
}
}
}
}
objLI_Current = objLI;
}
}
//-----------------------------------------------
// LoadNodeContent(objLI)
//-----------------------------------------------
function LoadNodeContent(objLI)
{
var objSPAN;
var objA;
objSPAN = GetHtmlElement(objLI,"SPAN","label");
if (objSPAN != null)
{
objA = GetHtmlElement(objSPAN,"A")
if (objA != null)
{
var sTmpArray = new Array();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -