//漫画书数组
var cdata = new Array();
function search_comic_book()
{
//æœç´¢æ¡†ç›’å
var bookKeyword = document.getElementById("book-keyword"),
//当å‰å…³é”®å—
currentKeyword = "",
//结果盒å
searchResult = document.getElementById('search-result'),
//展示æœç´¢ç»“æžœ
timeVar = setInterval(function(){
console.log (bookKeyword.value + " ==> N");
if(bookKeyword.value == currentKeyword || bookKeyword.value == '' || cdata.length == 0)
{
return;
}
var tpl = null,idx = -1,Rex = new RegExp(bookKeyword.value,'img');
searchResult['style']['display'] = 'block';
searchResult.innerHTML = '';
for(var i in cdata)
{
if( cdata[i]['name'].match(Rex) )
{
tpl = searchResult.getElementsByTagName('A')[0].cloneNode(true);
tpl.setAttribute("href","/manhua/"+cdata[i]['id']+'.htm');
tpl.innerHTML = cdata[i]['name'];
tpl['style']['display'] = 'block';
searchResult.appendChild(tpl);
if(++idx > 10)
{
tpl = searchResult.getElementsByTagName('A')[0].cloneNode(true);
tpl.setAttribute("href","/list-1-k"+bookKeyword.value+".htm");
tpl.innerHTML = "<< 查看更多结果 >>";
tpl['style']['display'] = 'block';
tpl['style']['text-align'] = 'center';
searchResult.appendChild(tpl);
break;
}
}
}
currentKeyword = bookKeyword.value;
},100);
bookKeyword.value = "";
if(cdata.length == 0)
{
var JS = document.createElement("SCRIPT");
JS.setAttribute("id","damotu-books");
JS.setAttribute("src","/js/book.htm");
document.getElementsByTagName('HEAD')[0].appendChild(JS);
JS.onload = function(){
cdata = bookData;
JS.parentNode.removeChild(JS);
}
}
document.addEventListener('click',function(){
searchResult['style']['display'] = 'none';
});
}