⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 langref.js

📁 关于windows使用的一些文章收集,希望对入门者能有所帮助
💻 JS
📖 第 1 页 / 共 2 页
字号:
					word = word.replace(/:.+/, "");

				if (word.length > 0) {
					var ichStart = strSyn.indexOf('>', 0) + 1;
					var ichBrace = strSyn.indexOf('{', ichStart);
					if (ichBrace < 0)
						ichBrace = strSyn.indexOf('(', ichStart);
					ichBrace = (ichBrace < 0) ? ichStart : ichBrace + 1;

					var ichMatch = findTerm(strSyn, ichBrace, word);
					if (ichMatch < 0 && ichStart < ichBrace)
						ichMatch = findTerm(strSyn, ichStart, word);

					while (ichMatch > 0) {
						var strTag = '<A HREF="" ONCLICK="showTip(this)" CLASS="synParam">' + word + '</A>';

						strSyn =
							strSyn.slice(0, ichMatch) +
							strTag +
							strSyn.slice(ichMatch + word.length);

						ichMatch = findTerm(strSyn, ichMatch + strTag.length, word);
					} 
				} 
			} 
		} 
	} 

	// Replace the syntax block with our modified version.
	pre.outerHTML = strSyn;
} 

function findTerm(strSyn, ichPos, strTerm)
{
	var ichMatch = strSyn.indexOf(strTerm, ichPos);
	while (ichMatch >= 0) {
		var prev = (ichMatch == 0) ? '\0' : strSyn.charAt(ichMatch - 1);
		var next = strSyn.charAt(ichMatch + strTerm.length);
		if (!isalnum(prev) && !isalnum(next) && !isInTag(strSyn, ichMatch)) {
			var ichComment = strSyn.indexOf("/*", ichPos);
			while (ichComment >= 0) {
				if (ichComment > ichMatch) {
					ichComment = -1;
					break; 
				} 
				var ichEnd = strSyn.indexOf("*/", ichComment);
				if (ichEnd < 0 || ichEnd > ichMatch)
					break;
				ichComment = strSyn.indexOf("/*", ichEnd);
			} 
			if (ichComment < 0) {
				ichComment = strSyn.indexOf("//", ichPos);
				while (ichComment >= 0) {
					if (ichComment > ichMatch) {
						ichComment = -1;
						break; 
					} 
					var ichEnd = strSyn.indexOf("\n", ichComment);
					if (ichEnd < 0 || ichEnd > ichMatch)
						break;
					ichComment = strSyn.indexOf("//", ichEnd);
				} 
			} 
			if (ichComment < 0)
				break;
		} 
		ichMatch = strSyn.indexOf(strTerm, ichMatch + strTerm.length);
	} 
	return ichMatch;
} 

function isInTag(strHtml, ichPos)
{
	return strHtml.lastIndexOf('<', ichPos) >
		strHtml.lastIndexOf('>', ichPos);
} 

function isalnum(ch)
{
	return ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == '_'));
} 

function showTip(link)
{
	bodyOnClick();

	var tip = document.all.reftip;
	if (!tip || !link)
		return;

	window.event.returnValue = false;
	window.event.cancelBubble = true;

	// Hide the tip if necessary and initialize its size.
	tip.style.visibility = "hidden";
	tip.style.pixelWidth = 260;
	tip.style.pixelHeight = 24;

	// Find the link target.
	var term = null;
	var def = null;
	var DLs = document.all.tags("DL");
	for (var iDL = 0; iDL < DLs.length; iDL++) {
		if (DLs[iDL].sourceIndex > link.sourceIndex) {
			var dl = DLs[iDL];
			var iMax = dl.children.length - 1;
			for (var iElem = 0; iElem < iMax; iElem++) {
				var dt = dl.children[iElem];
				if (dt.tagName == "DT" && dt.style.display != "none") {
					if (findTerm(dt.innerText, 0, link.innerText) >= 0) {
						var dd = dl.children[iElem + 1];
						if (dd.tagName == "DD") {
							term = dt;
							def = dd;
						} 
						break;
					} 
				} 
			} 
			break;
		} 
	} 

	if (def) {
		window.linkElement = link;
		window.linkTarget = term;
		tip.innerHTML = '<DL><DT>' + term.innerHTML + '</DT><DD>' + def.innerHTML + '</DD></DL>';
		window.setTimeout("moveTip()", 0);
	} 
} 

function jumpParam()
{
	hideTip();

	window.linkTarget.scrollIntoView();
	document.body.scrollLeft = 0;

	flash(3);
} 

function flash(c)
{
	window.linkTarget.style.background = (c & 1) ? "#CCCCCC" : "";
	if (c)
		window.setTimeout("flash(" + (c-1) + ")", 200);
} 

function moveTip()
{
	var tip = document.all.reftip;
	var link = window.linkElement;
	if (!tip || !link)
		return; //error

	var w = tip.offsetWidth;
	var h = tip.offsetHeight;

	if (w > tip.style.pixelWidth) {
		tip.style.pixelWidth = w;
		window.setTimeout("moveTip()", 0);
		return;
	} 

	var maxw = document.body.clientWidth;
	var maxh = document.body.clientHeight;

	if (h > maxh) {
		if (w < maxw) {
			w = w * 3 / 2;
			tip.style.pixelWidth = (w < maxw) ? w : maxw;
			window.setTimeout("moveTip()", 0);
			return;
		} 
	} 

	var x,y;

	var linkLeft = link.offsetLeft - document.body.scrollLeft;
	var linkRight = linkLeft + link.offsetWidth;

	var linkTop = link.offsetTop - document.body.scrollTop;
	var linkBottom = linkTop + link.offsetHeight;

	var cxMin = link.offsetWidth - 24;
	if (cxMin < 16)
		cxMin = 16;

	if (linkLeft + cxMin + w <= maxw) {
		x = maxw - w;
		if (x > linkRight + 8)
			x = linkRight + 8;
		y = maxh - h;
		if (y > linkTop)
			y = linkTop;
	} 
	else if (linkBottom + h <= maxh) {
		x = maxw - w;
		if (x < 0)
			x = 0;
		y = linkBottom;
	} 
	else if (w <= linkRight - cxMin) {
		x = linkLeft - w - 8;
		if (x < 0)
			x = 0;
		y = maxh - h;
		if (y > linkTop)
			y = linkTop;
	} 
	else if (h <= linkTop) {
		x = maxw - w;
		if (x < 0)
			x = 0;
		y = linkTop - h;
	} 
	else if (w >= maxw) {
		x = 0;
		y = linkBottom;
	} 
	else {
		w = w * 3 / 2;
		tip.style.pixelWidth = (w < maxw) ? w : maxw;
		window.setTimeout("moveTip()", 0);
		return;
	} 

	link.style.background = "#FFFF80";
	tip.style.pixelLeft = x + document.body.scrollLeft;
	tip.style.pixelTop = y + document.body.scrollTop;
	tip.style.visibility = "visible";
} 

function hideTip()
{
	if (window.linkElement) {
		window.linkElement.style.background = "";
		window.linkElement = null;
	} 

	var tip = document.all.reftip;
	if (tip) {
		tip.style.visibility = "hidden";
		tip.innerHTML = "";
	} 
} 

function beginsWith(s1, s2)
{
	// Does s1 begin with s2?
	return s1.substring(0, s2.length) == s2;
} 

//
// See Also popups
//
function initSeeAlso()
{
	// Localizable strings.
	var L_See_Also = "See Also";
	var L_Requirements = "Requirements";
	var L_QuickInfo = "QuickInfo";

	var hdr = document.all.hdr;
	if (!hdr)
		return;

	var divS = new String;
	var divR = new String;

	var heads = document.all.tags("H4");
	if (heads) {
		for (var i = 0; i < heads.length; i++) {
			var head = heads[i];
			var txt = head.innerText;
			if (beginsWith(txt, L_See_Also)) {
				divS += head.outerHTML;
				var next = getNext(head);
				while (next && !next.tagName.match(/^(H[1-4]|DIV)$/)) {
					divS += next.outerHTML;
					next = getNext(next);
				} 
			} 
			else if (beginsWith(txt, L_Requirements) || beginsWith(txt, L_QuickInfo)) {
				divR += head.outerHTML;
				var next = getNext(head);
				while (next && !next.tagName.match(/^(H[1-4]|DIV)$/)) {
					divR += next.outerHTML;
					next = getNext(next);
				} 
			} 
		} 
	} 

	var pos = getNext(hdr.parentElement);
	if (pos) {
		if (divR != "") {
			divR = '<DIV ID=rpop CLASS=sapop>' + divR + '</DIV>';
			var td = hdr.insertCell(0);
			if (td) {
				td.className = "button1";
				td.style.width = "19px";
				td.onclick = showRequirements;
				td.innerHTML = '<IMG SRC="' + baseUrl + 'Requirements.gif' + '" ALT="' + L_Requirements + '" BORDER=0>';
				if (ieVer == 4)
					document.body.insertAdjacentHTML('AfterBegin', divR);
				else
					document.body.insertAdjacentHTML('BeforeEnd', divR);
			} 
		} 
		if (divS != "") {
			divS = '<DIV ID=sapop CLASS=sapop>' + divS + '</DIV>';
			var td = hdr.insertCell(0);
			if (td) {
				td.className = "button1";
				td.style.width = "19px";
				td.onclick = showSeeAlso;
				td.innerHTML = '<IMG SRC="' + baseUrl + 'SeeAlso.gif' + '" ALT="' + L_See_Also + '" BORDER=0>';
				if (ieVer == 4)
					document.body.insertAdjacentHTML('AfterBegin', divS);
				else
					document.body.insertAdjacentHTML('BeforeEnd', divS);
			} 
		} 
	} 
} 

function showSeeAlso()
{
	bodyOnClick();

	window.event.returnValue = false;
	window.event.cancelBubble = true;

	var div = document.all.sapop;
	var lnk = window.event.srcElement;

	if (div && lnk) {
		div.style.pixelTop = lnk.offsetTop + lnk.offsetHeight;
		div.style.visibility = "visible";
	} 
} 

function showRequirements()
{
	bodyOnClick();

	window.event.returnValue = false;
	window.event.cancelBubble = true;

	var div = document.all.rpop;
	var lnk = window.event.srcElement;

	if (div && lnk) {
		div.style.pixelTop = lnk.offsetTop + lnk.offsetHeight;
		div.style.visibility = "visible";
	} 
} 

function hideSeeAlso()
{
	var div = document.all.sapop;
	if (div)
		div.style.visibility = "hidden";

	var div = document.all.rpop;
	if (div)
		div.style.visibility = "hidden";
} 


// Additions

function InitNewRefTips()
{
	var oTipLinks = document.all.tags("A");
	var index = 0;
	var oCurrentTip = null;
	

	for(index = 0; index < oTipLinks.length; index++)
	{
		oCurrentTip = oTipLinks[index];
		
		if(oCurrentTip.className == "classNewTipLink")
		{
			oCurrentTip.onclick = HandleNewRefTip;
		} 
	} 
} 

function HandleNewRefTip(oTip)
{
	ShowNewTip(this.innerText);			
} 

function ShowNewTip(tipIdentifier)
{
	var oTip = document.all(tipIdentifier);
	var w = oTip.offsetWidth;
	var h = oTip.offsetHeight;
	var maxw = document.body.clientWidth;
	var maxh = document.body.clientHeight;
	var currentPixelWidth = oTip.style.pixelWidth;
	var currentPixelHeight = oTip.style.pixelHeight;

	window.event.returnValue = false;
	window.event.cancelBubble = true;

	HideNewTips();	

	window.linkElement = window.event.srcElement;
	window.setTimeout("moveNewTip('" + tipIdentifier +"')" ,0)


} 

function HideNewTips()
{
	var oOld = document.all.tags("div");
	var i = 0;

	if (window.linkElement) {
		window.linkElement.style.background = "";
		window.linkElement = null;
	} 

	for(i=0;i<oOld.length;i++)
	{
		if((oOld(i).style.visibility == "visible") && (oOld(i).className == "classNewTip"))
		{
			oOld(i).style.visibility = "hidden";
			oOld(i).style.display = "none";
		} 
	} 
} 


function moveNewTip( tipIdentifier)
{
	var tip = document.all(tipIdentifier);
	var link = window.linkElement;
	if (!tip || !link)
		return; //error

	var w = tip.offsetWidth;
	var h = tip.offsetHeight;
	tip.style.display = "block";


	if (w > tip.style.pixelWidth) {
		tip.style.pixelWidth = w;
		window.setTimeout("moveNewTip('" + tipIdentifier +"')" ,0)
		return;
	} 

	var maxw = document.body.clientWidth;
	var maxh = document.body.clientHeight;

	if (h > maxh) {
		if (w < maxw) {
			w = w * 3 / 2;
			tip.style.pixelWidth = (w < maxw) ? w : maxw;
			window.setTimeout("moveNewTip('" + tipIdentifier +"')" ,0)
			return;
		} 
	} 

	var x,y;

	var linkLeft = link.offsetLeft - document.body.scrollLeft;
	var linkRight = linkLeft + link.offsetWidth;

	var linkTop = link.offsetTop - document.body.scrollTop;
	var linkBottom = linkTop + link.offsetHeight;

	var cxMin = link.offsetWidth - 24;
	if (cxMin < 16)
		cxMin = 16;

	if (linkLeft + cxMin + w <= maxw) {
		x = maxw - w;
		if (x > linkRight + 8)
			x = linkRight + 8;
		y = maxh - h;
		if (y > linkTop)
			y = linkTop;
	} 
	else if (linkBottom + h <= maxh) {
		x = maxw - w;
		if (x < 0)
			x = 0;
		y = linkBottom;
	} 
	else if (w <= linkRight - cxMin) {
		x = linkLeft - w - 8;
		if (x < 0)
			x = 0;
		y = maxh - h;
		if (y > linkTop)
			y = linkTop;
	} 
	else if (h <= linkTop) {
		x = maxw - w;
		if (x < 0)
			x = 0;
		y = linkTop - h;
	} 
	else if (w >= maxw) {
		x = 0;
		y = linkBottom;
	} 
	else {
		w = w * 3 / 2;
		tip.style.pixelWidth = (w < maxw) ? w : maxw;
		window.setTimeout("moveNewTip('" + tipIdentifier +"')" ,0)
		return;
	} 

	link.style.background = "#FFFF80";
	tip.style.pixelLeft = x + document.body.scrollLeft;
	tip.style.pixelTop = y + document.body.scrollTop;
	tip.style.visibility = "visible";
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -