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

📄 leadcode.js

📁 vc++功能文档
💻 JS
📖 第 1 页 / 共 3 页
字号:
while (p.nodeType == 3){p = p.previousSibling;}
return p;
}

function lead_multtb(s)
{
	var str = s;
	var oldstr = "",tmp;
	tmp = str.toLowerCase();
	while(oldstr != str)
	{	oldstr = str;
		str = str.replace(/\[table\](.+?)\[\/table\]/gim,"<table class=anctb>$1</table>");
		str = str.replace(/\[table=([#0-9a-z]{1,12}),([0-9]{1,3}),([0-9]{1,3}),([0-9\%\|\"\&quot\;]{1,12}),(left|center|right),([#0-9a-z]{1,12}),([0-9]{1,3}),(.+?)\](.+?)\[\/table\]/gim,function($0,$1,$2,$3,$4,$5,$6,$7,$8,$9){return("<table borderColor=" + $1 + " cellSpacing=" + $2 + " cellPadding=" + $3 + " width=" + $4 + " align=" + $5 + " bgColor=" + $6 + " background=\"" + url_filter($8) + "\" border=" + $7 + ">" + $9+ "</table>")});
		tmp = str.toLowerCase();
	}
	return(str);
}


var loadingImage = 'inc/pic/loading.gif';		
var closeButton = 'inc/pic/close.gif';		

function getPageScroll(){

	var yScl;

	if (self.pageYOffset) {
		yScl = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScl = document.documentElement.scrollTop;
	} else if (document.body) {
		yScl = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScl) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScl, yScl;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScl = document.body.scrollWidth;
		yScl = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScl = document.body.scrollWidth;
		yScl = document.body.scrollHeight;
	} else {
		xScl = document.body.offsetWidth;
		yScl = document.body.offsetHeight;
	}
	
	var wW, wH;
	if (self.innerHeight) {
		wW = self.innerWidth;
		wH = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		wW = document.documentElement.clientWidth;
		wH = document.documentElement.clientHeight;
	} else if (document.body) {
		wW = document.body.clientWidth;
		wH = document.body.clientHeight;
	}	

	if(yScl < wH){
		pageHeight = wH;
	} else { 
		pageHeight = yScl;
	}

	if(xScl < wW){	
		pageWidth = wW;
	} else {
		pageWidth = xScl;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,wW,wH) 
	return arrayPageSize;
}


function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function getKey(e){
	if (e == null) {
		keycode = event.keyCode;
	} else {
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){ hideLightbox(); }
}


function listenKey () {	document.onkeypress = getKey; }

function showLightbox(objLink)
{
	var objOvl = $('overlay');
	var oLB = $('lightbox');
	var objImage = $('lightboxImage');
	var LI = $('loadingImage');

	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	if (LI) {
		LI.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - LI.height) / 2) + 'px');
		LI.style.left = (((arrayPageSize[0] - 20 - LI.width) / 2) + 'px');
		LI.style.display = 'block';
	}

	objOvl.style.height = (arrayPageSize[1] + 'px');
	objOvl.style.display = 'block';

	imgPreload = new Image();

	imgPreload.onload=function(){
		objImage.src = objLink.src;
		objImage.border = 0;

		var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - imgPreload.height) / 2);
		var lightboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);
		
		oLB.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		oLB.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
		
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(250);
		} 

		if (LI) {	LI.style.display = 'none'; }

		selects = document.getElementsByTagName("select");
        for (i = 0; i != selects.length; i++) {
                selects[i].style.visibility = "hidden";
        }

	
		oLB.style.display = 'block';

		arrayPageSize = getPageSize();
		objOvl.style.height = (arrayPageSize[1] + 'px');
		
		listenKey();

		return false;
	}

	imgPreload.src = objLink.src;
	imgPreload.border = 0;
	
}

function hideLightbox()
{
	objOvl = $('overlay');
	oLB = $('lightbox');

	objOvl.style.display = 'none';
	oLB.style.display = 'none';

	selects = document.getElementsByTagName("select");
    for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
	document.onkeypress = '';
}


function initLightbox()
{
	
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("img");

	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("src") && (anchor.getAttribute("rel") == "lightbox") && anchor.parentNode.tagName != "A" && anchor.parentNode.tagName != "a"){
			anchor.onclick = function () {showLightbox(this); return false;}
			anchor.style.cursor = "hand";
		}
	}

	var objBody = document.getElementsByTagName("body").item(0);
	
	var objOvl = document.createElement("div");
	objOvl.setAttribute('id','overlay');
	objOvl.onclick = function () {hideLightbox(); return false;}
	objOvl.style.background = "url(" + HU + "a/inc/pic/overlay.png)";
	objOvl.style.display = 'none';
	objOvl.style.position = 'absolute';
	objOvl.style.top = '0';
	objOvl.style.left = '0';
	objOvl.style.zIndex = '90';
 	objOvl.style.width = '100%';
	objBody.insertBefore(objOvl, objBody.firstChild);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	var imgPreloader = new Image();
	
	imgPreloader.onload=function(){

		var LILink = document.createElement("a");
		LILink.setAttribute('href','#');
		LILink.onclick = function () {hideLightbox(); return false;}
		objOvl.appendChild(LILink);
		
		var LI = document.createElement("img");
		LI.src = loadingImage;
		LI.border = 0;
		LI.setAttribute('id','loadingImage');
		LI.style.position = 'absolute';
		LI.style.zIndex = '150';
		LILink.appendChild(LI);

		imgPreloader.onload=function(){};

		return false;
	}

	imgPreloader.src = loadingImage;
	imgPreloader.border = 0;

	var oLB = document.createElement("div");
	oLB.setAttribute('id','lightbox');
	oLB.style.background = '#eee';
	oLB.style.padding = '5px';
	oLB.style.background = '#eee';
	oLB.style.background = '#eee';
	oLB.style.display = 'none';
	oLB.style.position = 'absolute';
	oLB.style.zIndex = '100';	
	objBody.insertBefore(oLB, objOvl.nextSibling);
	
	var objLink = document.createElement("a");
	objLink.setAttribute('href','#');
	objLink.setAttribute('title','Click to close');
	objLink.onclick = function () {hideLightbox(); return false;}
	oLB.appendChild(objLink);

	var PreldCB = new Image();

	PreldCB.onload=function(){

		var oCB = document.createElement("img");
		oCB.src = closeButton;
		oCB.border = 0;
		oCB.setAttribute('id','closeButton');
		oCB.style.position = 'absolute';
		oCB.style.zIndex = '200';
		oCB.style.zIndex = '200';
		oCB.style.top = '0px';
		oCB.style.right = '0px';
		objLink.appendChild(oCB);

		return false;
	}

	PreldCB.src = closeButton;
	PreldCB.border = 0;

	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
	objLink.appendChild(objImage);
	
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}
addLoadEvent(initLightbox);

⌨️ 快捷键说明

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