📄 toc.js
字号:
}
if(lastNode != null)
lastNode.className = "UnselectedNode";
div.className = "Visible";
img.src = "Expanded.gif";
if(node.tagName == "A")
{
node.className = "SelectedNode";
lastNode = node;
}
if(div.innerHTML == "")
FillNode(div, false)
return true;
}
// Set the style of the specified node to "selected"
function SelectNode(node)
{
// If not valid, don't bother
if(GetCurrentUrl() == "")
return false;
if(lastNode != null)
lastNode.className = "UnselectedNode";
node.className = "SelectedNode";
lastNode = node;
return true;
}
//============================================================================
// Ajax-related code used to fill the tree nodes on demand
function GetXmlHttpRequest()
{
var xmlHttp = null;
// If IE7, Mozilla, Safari, etc., use the native object.
// Otherwise, use the ActiveX control for IE5.x and IE6.
if(window.XMLHttpRequest)
xmlHttp = new XMLHttpRequest();
else
if(window.ActiveXObject)
xmlHttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
return xmlHttp;
}
// Perform an AJAX-style request for the contents of a node and put the
// contents into the empty div.
function FillNode(div, expandChildren)
{
var xmlHttp = GetXmlHttpRequest(), now = new Date();
if(xmlHttp == null)
{
div.innerHTML = "<b>XML HTTP request not supported!</b>";
return;
}
div.innerHTML = "Loading...";
// Add a unique hash to ensure it doesn't use cached results
xmlHttp.open("GET", "FillNode.aspx?Id=" + div.id + "&hash=" +
now.getTime(), true);
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
div.innerHTML = xmlHttp.responseText;
if(expandChildren)
ExpandOrCollapseAll(true);
}
}
xmlHttp.send(null)
}
//============================================================================
// Resizing code
// Resize the tree div so that it fills the document body
function ResizeTree()
{
var y, newHeight;
if(self.innerHeight) // All but IE
y = self.innerHeight;
else // IE - Strict
if(document.documentElement && document.documentElement.clientHeight)
y = document.documentElement.clientHeight;
else // Everything else
if(document.body)
y = document.body.clientHeight;
newHeight = y - parseInt(divNavOpts.style.height) - 6;
if(newHeight < 50)
newHeight = 50;
divTree.style.height = newHeight;
newHeight = y - parseInt(divSearchOpts.style.height) - 6;
if(newHeight < 100)
newHeight = 100;
divSearchResults.style.height = newHeight;
// Resize the content div
ResizeContent();
}
// Resize the content div
function ResizeContent()
{
if(isIE)
maxWidth = docBody.clientWidth;
else
maxWidth = docBody.clientWidth - 4;
topicContent.style.width = maxWidth - (divSizer.offsetLeft +
divSizer.offsetWidth);
maxWidth -= minWidth;
}
// This is called to prepare for dragging the sizer div
function OnMouseDown(event)
{
var x;
// Make sure the splitter is at the top of the z-index
divSizer.style.zIndex = 5000;
// The content is in an IFRAME which steals mouse events so
// hide it while resizing.
topicContent.style.display = "none";
if(isIE)
x = window.event.clientX + document.documentElement.scrollLeft +
document.body.scrollLeft;
else
x = event.clientX + window.scrollX;
// Save starting offset
offset = parseInt(divSizer.style.left, 10);
if(isNaN(offset))
offset = 0;
offset -= x;
if(isIE)
{
document.attachEvent("onmousemove", OnMouseMove);
document.attachEvent("onmouseup", OnMouseUp);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
else
{
document.addEventListener("mousemove", OnMouseMove, true);
document.addEventListener("mouseup", OnMouseUp, true);
event.preventDefault();
}
}
// Resize the TOC and content divs as the sizer is dragged
function OnMouseMove(event)
{
var x, pos;
// Get cursor position with respect to the page
if(isIE)
x = window.event.clientX + document.documentElement.scrollLeft +
document.body.scrollLeft;
else
x = event.clientX + window.scrollX;
left = offset + x;
// Adjusts the width of the TOC divs
pos = (event.clientX > maxWidth) ? maxWidth :
(event.clientX < minWidth) ? minWidth : event.clientX;
divTOC.style.width = divSearchResults.style.width =
divTree.style.width = pos;
if(!isIE)
pos -= 8;
divNavOpts.style.width = divSearchOpts.style.width = pos;
// Resize the content div to fit in the remaining space
ResizeContent();
}
// Finish the drag operation when the mouse button is released
function OnMouseUp(event)
{
if(isIE)
{
document.detachEvent("onmousemove", OnMouseMove);
document.detachEvent("onmouseup", OnMouseUp);
}
else
{
document.removeEventListener("mousemove", OnMouseMove, true);
document.removeEventListener("mouseup", OnMouseUp, true);
}
// Show the content div again
topicContent.style.display = "inline";
}
//============================================================================
// Search code
function ShowHideSearch(show)
{
if(show)
{
divNavOpts.style.display = divTree.style.display = "none";
divSearchOpts.style.display = divSearchResults.style.display = "";
}
else
{
divSearchOpts.style.display = divSearchResults.style.display = "none";
divNavOpts.style.display = divTree.style.display = "";
}
}
// When enter is hit in the search text box, do the search
function OnSearchTextKeyPress(evt)
{
if(evt.keyCode == 13)
{
PerformSearch();
return false;
}
return true;
}
// Perform a keyword search
function PerformSearch()
{
var xmlHttp = GetXmlHttpRequest(), now = new Date();
if(xmlHttp == null)
{
divSearchResults.innerHTML = "<b>XML HTTP request not supported!</b>";
return;
}
divSearchResults.innerHTML = "<span class=\"PaddedText\">Searching...</span>";
// Add a unique hash to ensure it doesn't use cached results
xmlHttp.open("GET", "SearchHelp.aspx?Keywords=" + txtSearchText.value +
"&SortByTitle=" + (chkSortByTitle.checked ? "true" : "false") +
"&hash=" + now.getTime(), true);
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4)
{
divSearchResults.innerHTML = xmlHttp.responseText;
lastSearchNode = divSearchResults.childNodes[0].childNodes[1];
if(lastSearchNode.tagName != "A")
lastSearchNode = lastSearchNode.nextSibling;
SelectSearchNode(lastSearchNode);
topicContent.src = lastSearchNode.href;
}
}
xmlHttp.send(null)
}
// Set the style of the specified search result node to "selected"
function SelectSearchNode(node)
{
if(lastSearchNode != null)
lastSearchNode.className = "UnselectedNode";
node.className = "SelectedNode";
lastSearchNode = node;
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -