Moving to git

This commit is contained in:
2017-09-02 20:35:32 -05:00
commit a64ae89fec
369 changed files with 14030 additions and 0 deletions

View File

@ -0,0 +1,624 @@
//===============================================================================================================
// System : Sandcastle Help File Builder
// File : branding-Website.js
// Author : Eric Woodruff (Eric@EWoodruff.us)
// Updated : 03/04/2015
// Note : Copyright 2014-2015, Eric Woodruff, All rights reserved
// Portions Copyright 2014 Sam Harwell, All rights reserved
//
// This file contains the methods necessary to implement the lightweight TOC and search functionality.
//
// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be
// distributed with the code. It can also be found at the project website: https://GitHub.com/EWSoftware/SHFB. This
// notice, the author's name, and all copyright notices must remain intact in all applications, documentation,
// and source files.
//
// Date Who Comments
// ==============================================================================================================
// 05/04/2014 EFW Created the code based on a combination of the lightweight TOC code from Sam Harwell and
// the existing search code from SHFB.
//===============================================================================================================
// Width of the TOC
var tocWidth;
// Search method (0 = To be determined, 1 = ASPX, 2 = PHP, anything else = client-side script
var searchMethod = 0;
// Table of contents script
// Initialize the TOC by restoring its width from the cookie if present
function InitializeToc()
{
tocWidth = parseInt(GetCookie("TocWidth", "280"));
ResizeToc();
$(window).resize(SetNavHeight)
}
function SetNavHeight()
{
$leftNav = $("#leftNav")
$topicContent = $("#TopicContent")
leftNavPadding = $leftNav.outerHeight() - $leftNav.height()
contentPadding = $topicContent.outerHeight() - $topicContent.height()
// want outer height of left navigation div to match outer height of content
leftNavHeight = $topicContent.outerHeight() - leftNavPadding
$leftNav.css("min-height", leftNavHeight + "px")
}
// Increase the TOC width
function OnIncreaseToc()
{
if(tocWidth < 1)
tocWidth = 280;
else
tocWidth += 100;
if(tocWidth > 680)
tocWidth = 0;
ResizeToc();
SetCookie("TocWidth", tocWidth);
}
// Reset the TOC to its default width
function OnResetToc()
{
tocWidth = 0;
ResizeToc();
SetCookie("TocWidth", tocWidth);
}
// Resize the TOC width
function ResizeToc()
{
var toc = document.getElementById("leftNav");
if(toc)
{
// Set TOC width
toc.style.width = tocWidth + "px";
var leftNavPadding = 10;
document.getElementById("TopicContent").style.marginLeft = (tocWidth + leftNavPadding) + "px";
// Position images
document.getElementById("TocResize").style.left = (tocWidth + leftNavPadding) + "px";
// Hide/show increase TOC width image
document.getElementById("ResizeImageIncrease").style.display = (tocWidth >= 680) ? "none" : "";
// Hide/show reset TOC width image
document.getElementById("ResizeImageReset").style.display = (tocWidth < 680) ? "none" : "";
}
SetNavHeight()
}
// Toggle a TOC entry between its collapsed and expanded state
function Toggle(item)
{
var isExpanded = $(item).hasClass("tocExpanded");
$(item).toggleClass("tocExpanded tocCollapsed");
if(isExpanded)
{
Collapse($(item).parent());
}
else
{
var childrenLoaded = $(item).parent().attr("data-childrenloaded");
if(childrenLoaded)
{
Expand($(item).parent());
}
else
{
var tocid = $(item).next().attr("tocid");
$.ajax({
url: "../toc/" + tocid + ".xml",
async: true,
dataType: "xml",
success: function(data)
{
BuildChildren($(item).parent(), data);
}
});
}
}
}
// HTML encode a value for use on the page
function HtmlEncode(value)
{
// Create an in-memory div, set it's inner text (which jQuery automatically encodes) then grab the encoded
// contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
}
// Build the child entries of a TOC entry
function BuildChildren(tocDiv, data)
{
var childLevel = +tocDiv.attr("data-toclevel") + 1;
var childTocLevel = childLevel >= 10 ? 10 : childLevel;
var elements = data.getElementsByTagName("HelpTOCNode");
var isRoot = true;
if(data.getElementsByTagName("HelpTOC").length == 0)
{
// The first node is the root node of this group, don't show it again
isRoot = false;
}
for(var i = elements.length - 1; i > 0 || (isRoot && i == 0); i--)
{
var childHRef, childId = elements[i].getAttribute("Url");
if(childId != null && childId.length > 5)
{
// The Url attribute has the form "html/{childId}.htm"
childHRef = childId.substring(5, childId.length);
childId = childId.substring(5, childId.lastIndexOf("."));
}
else
{
// The Id attribute is in raw form. There is no URL (empty container node). In this case, we'll
// just ignore it and go nowhere. It's a rare case that isn't worth trying to get the first child.
// Instead, we'll just expand the node (see below).
childHRef = "#";
childId = elements[i].getAttribute("Id");
}
var existingItem = null;
tocDiv.nextAll().each(function()
{
if(!existingItem && $(this).children().last("a").attr("tocid") == childId)
{
existingItem = $(this);
}
});
if(existingItem != null)
{
// First move the children of the existing item
var existingChildLevel = +existingItem.attr("data-toclevel");
var doneMoving = false;
var inserter = tocDiv;
existingItem.nextAll().each(function()
{
if(!doneMoving && +$(this).attr("data-toclevel") > existingChildLevel)
{
inserter.after($(this));
inserter = $(this);
$(this).attr("data-toclevel", +$(this).attr("data-toclevel") + childLevel - existingChildLevel);
if($(this).hasClass("current"))
$(this).attr("class", "toclevel" + (+$(this).attr("data-toclevel") + " current"));
else
$(this).attr("class", "toclevel" + (+$(this).attr("data-toclevel")));
}
else
{
doneMoving = true;
}
});
// Now move the existing item itself
tocDiv.after(existingItem);
existingItem.attr("data-toclevel", childLevel);
existingItem.attr("class", "toclevel" + childLevel);
}
else
{
var hasChildren = elements[i].getAttribute("HasChildren");
var childTitle = HtmlEncode(elements[i].getAttribute("Title"));
var expander = "";
if(hasChildren)
expander = "<a class=\"tocCollapsed\" onclick=\"javascript: Toggle(this);\" href=\"#!\"></a>";
var text = "<div class=\"toclevel" + childTocLevel + "\" data-toclevel=\"" + childLevel + "\">" +
expander + "<a data-tochassubtree=\"" + hasChildren + "\" href=\"" + childHRef + "\" title=\"" +
childTitle + "\" tocid=\"" + childId + "\"" +
(childHRef == "#" ? " onclick=\"javascript: Toggle(this.previousSibling);\"" : "") + ">" +
childTitle + "</a></div>";
tocDiv.after(text);
}
}
tocDiv.attr("data-childrenloaded", true);
}
// Collapse a TOC entry
function Collapse(tocDiv)
{
// Hide all the TOC elements after item, until we reach one with a data-toclevel less than or equal to the
// current item's value.
var tocLevel = +tocDiv.attr("data-toclevel");
var done = false;
tocDiv.nextAll().each(function()
{
if(!done && +$(this).attr("data-toclevel") > tocLevel)
{
$(this).hide();
}
else
{
done = true;
}
});
}
// Expand a TOC entry
function Expand(tocDiv)
{
// Show all the TOC elements after item, until we reach one with a data-toclevel less than or equal to the
// current item's value
var tocLevel = +tocDiv.attr("data-toclevel");
var done = false;
tocDiv.nextAll().each(function()
{
if(done)
{
return;
}
var childTocLevel = +$(this).attr("data-toclevel");
if(childTocLevel == tocLevel + 1)
{
$(this).show();
if($(this).children("a").first().hasClass("tocExpanded"))
{
Expand($(this));
}
}
else if(childTocLevel > tocLevel + 1)
{
// Ignore this node, handled by recursive calls
}
else
{
done = true;
}
});
}
// This is called to prepare for dragging the sizer div
function OnMouseDown(event)
{
document.addEventListener("mousemove", OnMouseMove, true);
document.addEventListener("mouseup", OnMouseUp, true);
event.preventDefault();
}
// Resize the TOC as the sizer is dragged
function OnMouseMove(event)
{
tocWidth = (event.clientX > 700) ? 700 : (event.clientX < 100) ? 100 : event.clientX;
ResizeToc();
}
// Finish the drag operation when the mouse button is released
function OnMouseUp(event)
{
document.removeEventListener("mousemove", OnMouseMove, true);
document.removeEventListener("mouseup", OnMouseUp, true);
SetCookie("TocWidth", tocWidth);
}
// Search functions
// Transfer to the search page from a topic
function TransferToSearchPage()
{
var searchText = document.getElementById("SearchTextBox").value.trim();
if(searchText.length != 0)
document.location.replace(encodeURI("../search.html?SearchText=" + searchText));
}
// Initiate a search when the search page loads
function OnSearchPageLoad()
{
var queryString = decodeURI(document.location.search);
if(queryString != "")
{
var idx, options = queryString.split(/[\?\=\&]/);
for(idx = 0; idx < options.length; idx++)
if(options[idx] == "SearchText" && idx + 1 < options.length)
{
document.getElementById("txtSearchText").value = options[idx + 1];
PerformSearch();
break;
}
}
}
// Perform a search using the best available method
function PerformSearch()
{
var searchText = document.getElementById("txtSearchText").value;
var sortByTitle = document.getElementById("chkSortByTitle").checked;
var searchResults = document.getElementById("searchResults");
if(searchText.length == 0)
{
searchResults.innerHTML = "<strong>Nothing found</strong>";
return;
}
searchResults.innerHTML = "Searching...";
// Determine the search method if not done already. The ASPX and PHP searches are more efficient as they
// run asynchronously server-side. If they can't be used, it defaults to the client-side script below which
// will work but has to download the index files. For large help sites, this can be inefficient.
if(searchMethod == 0)
searchMethod = DetermineSearchMethod();
if(searchMethod == 1)
{
$.ajax({
type: "GET",
url: encodeURI("SearchHelp.aspx?Keywords=" + searchText + "&SortByTitle=" + sortByTitle),
success: function(html)
{
searchResults.innerHTML = html;
}
});
return;
}
if(searchMethod == 2)
{
$.ajax({
type: "GET",
url: encodeURI("SearchHelp.php?Keywords=" + searchText + "&SortByTitle=" + sortByTitle),
success: function(html)
{
searchResults.innerHTML = html;
}
});
return;
}
// Parse the keywords
var keywords = ParseKeywords(searchText);
// Get the list of files. We'll be getting multiple files so we need to do this synchronously.
var fileList = [];
$.ajax({
type: "GET",
url: "fti/FTI_Files.json",
dataType: "json",
async: false,
success: function(data)
{
$.each(data, function(key, val)
{
fileList[key] = val;
});
}
});
var letters = [];
var wordDictionary = {};
var wordNotFound = false;
// Load the keyword files for each keyword starting letter
for(var idx = 0; idx < keywords.length && !wordNotFound; idx++)
{
var letter = keywords[idx].substring(0, 1);
if($.inArray(letter, letters) == -1)
{
letters.push(letter);
$.ajax({
type: "GET",
url: "fti/FTI_" + letter.charCodeAt(0) + ".json",
dataType: "json",
async: false,
success: function(data)
{
var wordCount = 0;
$.each(data, function(key, val)
{
wordDictionary[key] = val;
wordCount++;
});
if(wordCount == 0)
wordNotFound = true;
}
});
}
}
if(wordNotFound)
searchResults.innerHTML = "<strong>Nothing found</strong>";
else
searchResults.innerHTML = SearchForKeywords(keywords, fileList, wordDictionary, sortByTitle);
}
// Determine the search method by seeing if the ASPX or PHP search pages are present and working
function DetermineSearchMethod()
{
var method = 3;
try
{
$.ajax({
type: "GET",
url: "SearchHelp.aspx",
async: false,
success: function(html)
{
if(html.substring(0, 8) == "<strong>")
method = 1;
}
});
if(method == 3)
$.ajax({
type: "GET",
url: "SearchHelp.php",
async: false,
success: function(html)
{
if(html.substring(0, 8) == "<strong>")
method = 2;
}
});
}
catch(e)
{
}
return method;
}
// Split the search text up into keywords
function ParseKeywords(keywords)
{
var keywordList = [];
var checkWord;
var words = keywords.split(/\W+/);
for(var idx = 0; idx < words.length; idx++)
{
checkWord = words[idx].toLowerCase();
if(checkWord.length > 2)
{
var charCode = checkWord.charCodeAt(0);
if((charCode < 48 || charCode > 57) && $.inArray(checkWord, keywordList) == -1)
keywordList.push(checkWord);
}
}
return keywordList;
}
// Search for keywords and generate a block of HTML containing the results
function SearchForKeywords(keywords, fileInfo, wordDictionary, sortByTitle)
{
var matches = [], matchingFileIndices = [], rankings = [];
var isFirst = true;
for(var idx = 0; idx < keywords.length; idx++)
{
var word = keywords[idx];
var occurrences = wordDictionary[word];
// All keywords must be found
if(occurrences == null)
return "<strong>Nothing found</strong>";
matches[word] = occurrences;
var occurrenceIndices = [];
// Get a list of the file indices for this match. These are 64-bit numbers but JavaScript only does
// bit shifts on 32-bit values so we divide by 2^16 to get the same effect as ">> 16" and use floor()
// to truncate the result.
for(var ind in occurrences)
occurrenceIndices.push(Math.floor(occurrences[ind] / Math.pow(2, 16)));
if(isFirst)
{
isFirst = false;
for(var matchInd in occurrenceIndices)
matchingFileIndices.push(occurrenceIndices[matchInd]);
}
else
{
// After the first match, remove files that do not appear for all found keywords
for(var checkIdx = 0; checkIdx < matchingFileIndices.length; checkIdx++)
if($.inArray(matchingFileIndices[checkIdx], occurrenceIndices) == -1)
{
matchingFileIndices.splice(checkIdx, 1);
checkIdx--;
}
}
}
if(matchingFileIndices.length == 0)
return "<strong>Nothing found</strong>";
// Rank the files based on the number of times the words occurs
for(var fileIdx = 0; fileIdx < matchingFileIndices.length; fileIdx++)
{
// Split out the title, filename, and word count
var matchingIdx = matchingFileIndices[fileIdx];
var fileIndex = fileInfo[matchingIdx].split(/\0/);
var title = fileIndex[0];
var filename = fileIndex[1];
var wordCount = parseInt(fileIndex[2]);
var matchCount = 0;
for(var idx = 0; idx < keywords.length; idx++)
{
occurrences = matches[keywords[idx]];
for(var ind in occurrences)
{
var entry = occurrences[ind];
// These are 64-bit numbers but JavaScript only does bit shifts on 32-bit values so we divide
// by 2^16 to get the same effect as ">> 16" and use floor() to truncate the result.
if(Math.floor(entry / Math.pow(2, 16)) == matchingIdx)
matchCount += (entry & 0xFFFF);
}
}
rankings.push({ Filename: filename, PageTitle: title, Rank: matchCount * 1000 / wordCount });
if(rankings.length > 99)
break;
}
rankings.sort(function(x, y)
{
if(!sortByTitle)
return y.Rank - x.Rank;
return x.PageTitle.localeCompare(y.PageTitle);
});
// Format and return the results
var content = "<ol>";
for(var r in rankings)
content += "<li><a href=\"" + rankings[r].Filename + "\" target=\"_blank\">" +
rankings[r].PageTitle + "</a></li>";
content += "</ol>";
if(rankings.length < matchingFileIndices.length)
content += "<p>Omitted " + (matchingFileIndices.length - rankings.length) + " more results</p>";
return content;
}

View File

@ -0,0 +1,560 @@
//===============================================================================================================
// System : Sandcastle Help File Builder
// File : branding.js
// Author : Eric Woodruff (Eric@EWoodruff.us)
// Updated : 10/08/2015
// Note : Copyright 2014-2015, Eric Woodruff, All rights reserved
// Portions Copyright 2010-2014 Microsoft, All rights reserved
//
// This file contains the methods necessary to implement the language filtering, collapsible section, and
// copy to clipboard options.
//
// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be
// distributed with the code and can be found at the project website: https://GitHub.com/EWSoftware/SHFB. This
// notice, the author's name, and all copyright notices must remain intact in all applications, documentation,
// and source files.
//
// Date Who Comments
// ==============================================================================================================
// 05/04/2014 EFW Created the code based on the MS Help Viewer script
//===============================================================================================================
// The IDs of all code snippet sets on the same page are stored so that we can keep them in synch when a tab is
// selected.
var allTabSetIds = new Array();
// The IDs of language-specific text (LST) spans are used as dictionary keys so that we can get access to the
// spans and update them when the user changes to a different language tab. The values of the dictionary
// objects are pipe separated language-specific attributes (lang1=value|lang2=value|lang3=value). The language
// ID can be specific (cs, vb, cpp, etc.) or may be a neutral entry (nu) which specifies text common to multiple
// languages. If a language is not present and there is no neutral entry, the span is hidden for all languages
// to which it does not apply.
var allLSTSetIds = new Object();
// Help 1 persistence support. This code must appear inline.
var isHelp1;
var curLoc = document.location + ".";
if(curLoc.indexOf("mk:@MSITStore") == 0)
{
isHelp1 = true;
curLoc = "ms-its:" + curLoc.substring(14, curLoc.length - 1);
document.location.replace(curLoc);
}
else
if(curLoc.indexOf("ms-its:") == 0)
isHelp1 = true;
else
isHelp1 = false;
// The OnLoad method
function OnLoad(defaultLanguage)
{
var defLang;
if(typeof (defaultLanguage) == "undefined" || defaultLanguage == null || defaultLanguage == "")
defLang = "vb";
else
defLang = defaultLanguage;
// In MS Help Viewer, the transform the topic is ran through can move the footer. Move it back where it
// belongs if necessary.
try
{
var footer = document.getElementById("pageFooter")
if(footer)
{
var footerParent = document.body;
if(footer.parentElement != footerParent)
{
footer.parentElement.removeChild(footer);
footerParent.appendChild(footer);
}
}
}
catch(e)
{
}
var language = GetCookie("CodeSnippetContainerLanguage", defLang);
// If LST exists on the page, set the LST to show the user selected programming language
UpdateLST(language);
// If code snippet groups exist, set the current language for them
if(allTabSetIds.length > 0)
{
var i = 0;
while(i < allTabSetIds.length)
{
var tabCount = 1;
// The tab count may vary so find the last one in this set
while(document.getElementById(allTabSetIds[i] + "_tab" + tabCount) != null)
tabCount++;
tabCount--;
// If not grouped, skip it
if(tabCount > 1)
SetCurrentLanguage(allTabSetIds[i], language, tabCount);
i++;
}
}
InitializeToc();
}
// This is just a place holder. The website script implements this function to initialize it's in-page TOC pane
function InitializeToc()
{
}
// This function executes in the OnLoad event and ChangeTab action on code snippets. The function parameter
// is the user chosen programming language. This function iterates through the "allLSTSetIds" dictionary object
// to update the node value of the LST span tag per the user's chosen programming language.
function UpdateLST(language)
{
for(var lstMember in allLSTSetIds)
{
var devLangSpan = document.getElementById(lstMember);
if(devLangSpan != null)
{
// There may be a carriage return before the LST span in the content so the replace function below
// is used to trim the whitespace at the end of the previous node of the current LST node.
if(devLangSpan.previousSibling != null && devLangSpan.previousSibling.nodeValue != null)
devLangSpan.previousSibling.nodeValue = devLangSpan.previousSibling.nodeValue.replace(/\s+$/, "");
var langs = allLSTSetIds[lstMember].split("|");
var k = 0;
var keyValue;
while(k < langs.length)
{
keyValue = langs[k].split("=");
if(keyValue[0] == language)
{
devLangSpan.innerHTML = keyValue[1];
// Help 1 and MS Help Viewer workaround. Add a space if the following text element starts
// with a space to prevent things running together.
if(devLangSpan.parentNode != null && devLangSpan.parentNode.nextSibling != null)
{
if (devLangSpan.parentNode.nextSibling.nodeValue != null &&
!devLangSpan.parentNode.nextSibling.nodeValue.substring(0, 1).match(/[.,);:!/?]/))
{
devLangSpan.innerHTML = keyValue[1] + " ";
}
}
break;
}
k++;
}
// If not found, default to the neutral language. If there is no neutral language entry, clear the
// content to hide it.
if(k >= langs.length)
{
if(language != "nu")
{
k = 0;
while(k < langs.length)
{
keyValue = langs[k].split("=");
if(keyValue[0] == "nu")
{
devLangSpan.innerHTML = keyValue[1];
// Help 1 and MS Help Viewer workaround. Add a space if the following text element
// starts with a space to prevent things running together.
if(devLangSpan.parentNode != null && devLangSpan.parentNode.nextSibling != null)
{
if(devLangSpan.parentNode.nextSibling.nodeValue != null &&
!devLangSpan.parentNode.nextSibling.nodeValue.substring(0, 1).match(/[.,);:!/?]/))
{
devLangSpan.innerHTML = keyValue[1] + " ";
}
}
break;
}
k++;
}
}
if(k >= langs.length)
devLangSpan.innerHTML = "";
}
}
}
}
// Get the specified cookie. If not found, return the specified default value.
function GetCookie(cookieName, defaultValue)
{
if(isHelp1)
{
try
{
var globals = Help1Globals;
var value = globals.Load(cookieName);
if(value == null)
value = defaultValue;
return value;
}
catch(e)
{
return defaultValue;
}
}
var cookie = document.cookie.split("; ");
for(var i = 0; i < cookie.length; i++)
{
var crumb = cookie[i].split("=");
if(cookieName == crumb[0])
return unescape(crumb[1])
}
return defaultValue;
}
// Set the specified cookie to the specified value
function SetCookie(name, value)
{
if(isHelp1)
{
try
{
var globals = Help1Globals;
globals.Save(name, value);
}
catch(e)
{
}
return;
}
var today = new Date();
today.setTime(today.getTime());
// Set the expiration time to be 60 days from now (in milliseconds)
var expires_date = new Date(today.getTime() + (60 * 1000 * 60 * 60 * 24));
document.cookie = name + "=" + escape(value) + ";expires=" + expires_date.toGMTString() + ";path=/";
}
// Add a language-specific text ID
function AddLanguageSpecificTextSet(lstId)
{
var keyValue = lstId.split("?")
allLSTSetIds[keyValue[0]] = keyValue[1];
}
var clipboardHandler;
// Add a language tab set ID
function AddLanguageTabSet(tabSetId)
{
allTabSetIds.push(tabSetId);
// Create the clipboard handler on first use
if(clipboardHandler == null && typeof (Clipboard) == "function")
{
clipboardHandler = new Clipboard('.copyCodeSnippet',
{
text: function (trigger)
{
// Get the code to copy to the clipboard from the active tab of the given tab set
var i = 1, tabSetId = trigger.id;
var pos = tabSetId.indexOf('_');
if(pos == -1)
return "";
tabSetId = tabSetId.substring(0, pos);
do
{
contentId = tabSetId + "_code_Div" + i;
tabTemp = document.getElementById(contentId);
if(tabTemp != null && tabTemp.style.display != "none")
break;
i++;
} while(tabTemp != null);
if(tabTemp == null)
return "";
return document.getElementById(contentId).innerText;
}
});
}
}
// Switch the active tab for all of other code snippets
function ChangeTab(tabSetId, language, snippetIdx, snippetCount)
{
SetCookie("CodeSnippetContainerLanguage", language);
SetActiveTab(tabSetId, snippetIdx, snippetCount);
// If LST exists on the page, set the LST to show the user selected programming language
UpdateLST(language);
var i = 0;
while(i < allTabSetIds.length)
{
// We just care about other snippets
if(allTabSetIds[i] != tabSetId)
{
// Other tab sets may not have the same number of tabs
var tabCount = 1;
while(document.getElementById(allTabSetIds[i] + "_tab" + tabCount) != null)
tabCount++;
tabCount--;
// If not grouped, skip it
if(tabCount > 1)
SetCurrentLanguage(allTabSetIds[i], language, tabCount);
}
i++;
}
}
// Sets the current language in the specified tab set
function SetCurrentLanguage(tabSetId, language, tabCount)
{
var tabIndex = 1;
while(tabIndex <= tabCount)
{
var tabTemp = document.getElementById(tabSetId + "_tab" + tabIndex);
if(tabTemp != null && tabTemp.innerHTML.indexOf("'" + language + "'") != -1)
break;
tabIndex++;
}
if(tabIndex > tabCount)
{
// Select the first non-disabled tab
tabIndex = 1;
if(document.getElementById(tabSetId + "_tab1").className == "codeSnippetContainerTabPhantom")
{
tabIndex++;
while(tabIndex <= tabCount)
{
var tab = document.getElementById(tabSetId + "_tab" + tabIndex);
if(tab.className != "codeSnippetContainerTabPhantom")
{
tab.className = "codeSnippetContainerTabActive";
document.getElementById(tabSetId + "_code_Div" + j).style.display = "block";
break;
}
tabIndex++;
}
}
}
SetActiveTab(tabSetId, tabIndex, tabCount);
}
// Set the active tab within a tab set
function SetActiveTab(tabSetId, tabIndex, tabCount)
{
var i = 1;
while(i <= tabCount)
{
var tabTemp = document.getElementById(tabSetId + "_tab" + i);
if (tabTemp != null)
{
if(tabTemp.className == "codeSnippetContainerTabActive")
tabTemp.className = "codeSnippetContainerTab";
else
if(tabTemp.className == "codeSnippetContainerTabPhantom")
tabTemp.style.display = "none";
var codeTemp = document.getElementById(tabSetId + "_code_Div" + i);
if(codeTemp.style.display != "none")
codeTemp.style.display = "none";
}
i++;
}
// Phantom tabs are shown or hidden as needed
if(document.getElementById(tabSetId + "_tab" + tabIndex).className != "codeSnippetContainerTabPhantom")
document.getElementById(tabSetId + "_tab" + tabIndex).className = "codeSnippetContainerTabActive";
else
document.getElementById(tabSetId + "_tab" + tabIndex).style.display = "block";
document.getElementById(tabSetId + "_code_Div" + tabIndex).style.display = "block";
}
// Copy the code from the active tab of the given tab set to the clipboard
function CopyToClipboard(tabSetId)
{
var tabTemp, contentId;
var i = 1;
if(typeof (Clipboard) == "function")
return;
do
{
contentId = tabSetId + "_code_Div" + i;
tabTemp = document.getElementById(contentId);
if(tabTemp != null && tabTemp.style.display != "none")
break;
i++;
} while(tabTemp != null);
if(tabTemp == null)
return;
if(window.clipboardData)
{
try
{
window.clipboardData.setData("Text", document.getElementById(contentId).innerText);
}
catch(e)
{
alert("Permission denied. Enable copying to the clipboard.");
}
}
else if(window.netscape)
{
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(
Components.interfaces.nsIClipboard);
if(!clip)
return;
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(
Components.interfaces.nsITransferable);
if(!trans)
return;
trans.addDataFlavor("text/unicode");
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(
Components.interfaces.nsISupportsString);
var copytext = document.getElementById(contentId).textContent;
str.data = copytext;
trans.setTransferData("text/unicode", str, copytext.length * 2);
var clipid = Components.interfaces.nsIClipboard;
clip.setData(trans, null, clipid.kGlobalClipboard);
}
catch(e)
{
alert("Permission denied. Enter \"about:config\" in the address bar and double-click the \"signed.applets.codebase_principal_support\" setting to enable copying to the clipboard.");
}
}
}
// Expand or collapse a section
function SectionExpandCollapse(togglePrefix)
{
var image = document.getElementById(togglePrefix + "Toggle");
var section = document.getElementById(togglePrefix + "Section");
if(image != null && section != null)
if(section.style.display == "")
{
image.src = image.src.replace("SectionExpanded.png", "SectionCollapsed.png");
section.style.display = "none";
}
else
{
image.src = image.src.replace("SectionCollapsed.png", "SectionExpanded.png");
section.style.display = "";
}
}
// Expand or collapse a section when it has the focus and Enter is hit
function SectionExpandCollapse_CheckKey(togglePrefix, eventArgs)
{
if(eventArgs.keyCode == 13)
SectionExpandCollapse(togglePrefix);
}
// Help 1 persistence object. This requires a hidden input element on the page with a class of "userDataStyle"
// defined in the style sheet that implements the user data binary behavior:
// <input type="hidden" id="userDataCache" class="userDataStyle" />
var Help1Globals =
{
UserDataCache: function()
{
var userData = document.getElementById("userDataCache");
return userData;
},
Load: function(key)
{
var userData = this.UserDataCache();
userData.load("userDataSettings");
var value = userData.getAttribute(key);
return value;
},
Save: function(key, value)
{
var userData = this.UserDataCache();
userData.setAttribute(key, value);
userData.save("userDataSettings");
}
};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,148 @@
//===============================================================================================================
// System : Color Syntax Highlighter
// File : Highlight.js
// Author : Eric Woodruff (Eric@EWoodruff.us)
// Updated : 10/21/2012
// Note : Copyright 2006-2012, Eric Woodruff, All rights reserved
//
// This contains the script to expand and collapse the regions in the syntax highlighted code.
//
// This is a customized version for the Sandcastle Help File Builder. It overrides the CopyCode() function
// from the Hana, Prototype, and VS2005 presentation styles to remove the line numbering and collapsible
// region elements. The VS2010 style does not currently use the CopyCode() function in here as it has its own
// version for copying the code.
//===============================================================================================================
// Expand/collapse a region
function HighlightExpandCollapse(showId, hideId)
{
var showSpan = document.getElementById(showId), hideSpan = document.getElementById(hideId);
showSpan.style.display = "inline";
hideSpan.style.display = "none";
}
// Copy the code from a colorized code block to the clipboard.
function CopyCode(key)
{
var idx, line, block, htmlLines, lines, codeText, hasLineNos, hasRegions, clip, trans,
copyObject, clipID;
var reLineNo = /^\s*\d{1,4}/;
var reRegion = /^\s*\d{1,4}\+.*?\d{1,4}-/;
var reRegionText = /^\+.*?\-/;
// Find the table row element containing the code
var trElements = document.getElementsByTagName("tr");
for(idx = 0; idx < trElements.length; idx++)
if(key.parentNode.parentNode.parentNode == trElements[idx].parentNode)
{
block = trElements[idx].nextSibling;
break;
}
if(block.innerText != undefined)
codeText = block.innerText;
else
codeText = block.textContent;
hasLineNos = block.innerHTML.indexOf("highlight-lineno");
hasRegions = block.innerHTML.indexOf("highlight-collapsebox");
htmlLines = block.innerHTML.split("\n");
lines = codeText.split("\n");
// Remove the line numbering and collapsible regions if present
if(hasLineNos != -1 || hasRegions != -1)
{
codeText = "";
for(idx = 0; idx < lines.length; idx++)
{
line = lines[idx];
if(hasRegions && reRegion.test(line))
line = line.replace(reRegion, "");
else
{
line = line.replace(reLineNo, "");
// Lines in expanded blocks have an extra space
if(htmlLines[idx].indexOf("highlight-expanded") != -1 ||
htmlLines[idx].indexOf("highlight-endblock") != -1)
line = line.substr(1);
}
if(hasRegions && reRegionText.test(line))
line = line.replace(reRegionText, "");
codeText += line;
// Not all browsers keep the line feed when split
if(line[line.length - 1] != "\n")
codeText += "\n";
}
}
// IE or FireFox/Netscape?
if(window.clipboardData)
window.clipboardData.setData("Text", codeText);
else
if(window.netscape)
{
// Give unrestricted access to browser APIs using XPConnect
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch(e)
{
alert("Universal Connect was refused, cannot copy to clipboard. Go to about:config and set " +
"signed.applets.codebase_principal_support to true to enable clipboard support.");
return;
}
// Creates an instance of nsIClipboard
clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(
Components.interfaces.nsIClipboard);
// Creates an instance of nsITransferable
if(clip)
trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(
Components.interfaces.nsITransferable);
if(!trans)
{
alert("Copy to Clipboard is not supported by this browser");
return;
}
// Register the data flavor
trans.addDataFlavor("text/unicode");
// Create object to hold the data
copyObject = new Object();
// Creates an instance of nsISupportsString
copyObject = Components.classes["@mozilla.org/supports-string;1"].createInstance(
Components.interfaces.nsISupportsString);
// Assign the data to be copied
copyObject.data = codeText;
// Add data objects to transferable
trans.setTransferData("text/unicode", copyObject, codeText.length * 2);
clipID = Components.interfaces.nsIClipboard;
if(!clipID)
{
alert("Copy to Clipboard is not supported by this browser");
return;
}
// Transfer the data to the clipboard
clip.setData(trans, null, clipID.kGlobalClipboard);
}
else
alert("Copy to Clipboard is not supported by this browser");
}

File diff suppressed because one or more lines are too long