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

📄 search.js

📁 EdisonMovie是由爱迪生工作室打造的完全面向中小站长的免费开源视频系统。采用PHP5+MYSQL5架构
💻 JS
字号:
var xmlHttp;
var bShow = false;
var bLoop = false;
var $=function(node){return document.getElementById(node);}
var iLen = 0;var iIndex = 0;var sKey = ""; var searchUrl = sitepath + '/ajax.php';
function fnGetResult(){
	if($("q").value=="")return false;
	if($("q").value==sKey)return false;
    xmlHttp = createXMLHttp();
	sKey = $("q").value;
    xmlHttp.onreadystatechange = fnHandle;
    xmlHttp.open("GET",searchUrl+"?m=media&q="+encodeURIComponent(sKey), true);
    xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
    xmlHttp.send();
}

function fnHandle(){
	if (xmlHttp.readyState==4){
		if (xmlHttp.status==200){
		   fnInitData(xmlHttp.responseText);
		}
	}
}

function fnInitData(data){
	iIndex = 0;
	if(eval(data)=='undefined')return false;
	var oData = eval(data);
	try{iLen = oData.length;}catch(e){}
	if(iLen==0){
		$("suggest").style.display = "none";
		bShow = false;
	}else{
		var sRet = "<ul>";
		for(var i=0;i<iLen;i++){
			sRet += "<li onclick=\"fnGoTo('" + oData[i].url + "')\" onmouseover=\"this.className=\'on\'\" onmouseout=\"this.className=''\"><em>" + oData[i].status + "</em>" + oData[i].title.replace(sKey,"<span>"+sKey+"</span>") + "</li>";
		}
		sRet += "</ul>";
		sRet += "<div><a href='javascript:void(0)' onclick='fnClose()'>×关闭</a></div>"
		$("suggest").innerHTML = sRet;
		$("suggest").style.display = "block";
		bShow = true;
	}
}

function fnClose(){
	$("suggest").style.display = "none";
}

function fnGoTo(id){
	window.location.href = sitepath + id;
}

function fnKeyup(e){
	var iKey = (window.event) ? e.keyCode : ((e.which)? e.which : 0);
	if(iKey==40||iKey==38){
		iIndex = (iKey==40) ? ((iIndex>=iLen)? 0 : ++iIndex) : ((iIndex<=0)?iLen:--iIndex);
		fnToogle(iIndex);
    }
	if($("q").value!="")
		fnGetResult();
}

function fnKeydown(e){
	var iKey = (window.event) ? e.keyCode : ((e.which)? e.which : 0);
	if(iKey==13){
		(iIndex>0) ?  document.getElementById("suggest").getElementsByTagName("li")[iIndex-1].onclick() : searchSend();
	}
}

function fnToogle(p){
	var oSuggest = document.getElementById("suggest").getElementsByTagName("li");
	for(var i=0;i<iLen;i++){
		oSuggest[i].className = "";
	}
	if(p>0)oSuggest[p-1].className = "on";
}

function fnLoop(){
	if(bLoop){
		fnGetResult();
	  //window.setTimeout('fnLoop()',300);
	}
}

function fnFocus(){
	bLoop = true;
	fnLoop();
}

function fnBlur(){
	bLoop = false;
	setTimeout('fnClose()',500);
}

function searchSend(){
	var el = $('q');
	if(el.value==''){
		window.alert('请输入影视名称!');
		el.focus();
		return false;
	}
//	var xmlHttp = createXMLHttp();
//	xmlHttp.open("POST",searchUrl+'?q=' + encodeURIComponent(el.value),false)
//	xmlHttp.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded" );
//	xmlHttp.onreadystatechange = function(){
//		if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
//			var text = xmlHttp.responseText;
//			eval(text);
//		}
//	}
//	xmlHttp.Send();
}
function createXMLHttp(){
    var ret = null;
    try {
        ret = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (e) {
        try {
            ret = new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch (ee) {
            ret = null;
        }
    }
    if (!ret && typeof XMLHttpRequest != 'undefined')
        ret = new XMLHttpRequest();
    return ret;
}
//window.onerror = function(){return true;}

⌨️ 快捷键说明

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