651 lines
22 KiB
HTML
651 lines
22 KiB
HTML
{eval
|
||
function tpl_cloudsearch_index_top($recwords, $searchparams, $srchotquery, $position = 'hotopicf') {
|
||
global $_G;
|
||
if($recwords) {
|
||
$recwords_tmp = $recwords;
|
||
$recwords = array();
|
||
foreach ($recwords_tmp as $k => $v) {
|
||
$recwords[$k+1] = $v;
|
||
}{eval }}{eval }}
|
||
<!--{block return}-->
|
||
<!--{if is_array($recwords) && count($recwords) > 0 && !empty($searchparams[url])}-->
|
||
<div class="fl bm">
|
||
<div class="bm bmw hottopic cl">
|
||
<div class="bm_h cl">
|
||
<span class="y"></span>
|
||
<h2>{if $_G['fid']}{lang cloudsearch:current}{/if}{lang cloudsearch:hottopic}</h2>
|
||
</div>
|
||
<style>
|
||
.filter { padding: 10px; border-bottom: none; font-size: 12px; color: #999; }
|
||
.filter ul {}
|
||
.filter li { float: left; margin-right: 16px; height: 22px; line-height: 22px; white-space:nowrap; width:12.5%; }
|
||
.filter li a { margin-right: 2px; text-decoration: none; color: #369; }
|
||
.filter li.clewcolor a { background:url(source/plugin/cloudsearch/template/keyword_hot.gif) no-repeat 100% 2px; margin-right: 2px; text-decoration: none; color: #F00; padding-right:18px; }
|
||
.filter li a:hover { text-decoration: underline; }
|
||
.filter li a:visited { text-decoration: none; color: #666; }
|
||
.filter li.clewcolor a:visited { text-decoration: none; color: #F00; }
|
||
.filter .number { color: #666; }
|
||
.filter li.clewcolor .number { color:#F00; }
|
||
</style>
|
||
<div class="filter">
|
||
<ul class="cl">
|
||
<!--{loop $recwords $key $recword}-->
|
||
<!--{if $encodeWord=rawurlencode(trim($recword[word]))}-->
|
||
<!--{if empty($recword[inc_num])}-->
|
||
<li><a href="$searchparams[url]?q=$encodeWord&source=word.$position.$key$srchotquery&num=$recword[result_num]" sc="1" target="_blank">$recword[word]<span class="number">($recword[result_num])</span></a></li>
|
||
<!--{else}-->
|
||
<li class="clewcolor"><a href="$searchparams[url]?q=$encodeWord&source=word.$position.$key$srchotquery&num=$recword[result_num]" sc="1" target="_blank">$recword[word]<span class="number">($recword[result_num])</span></a></li>
|
||
<!--{/if}-->
|
||
<!--{/if}-->
|
||
<!--{/loop}-->
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!--{/if}-->
|
||
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_global_footer_formula_output() {
|
||
global $_G;
|
||
$formHash = FORMHASH;
|
||
$cookie = $_G['cookie']['ffids' . $_G['uid']];
|
||
}
|
||
<!--{block return}-->
|
||
<!--{if !$cookie}-->
|
||
<script type="text/javascript">
|
||
_attachEvent(window, 'load', getForbiddenFormula, document);
|
||
function getForbiddenFormula() {
|
||
var toGetForbiddenFormulaFIds = function () {
|
||
ajaxget('plugin.php?id=cloudsearch&formhash={$formHash}');
|
||
};
|
||
var a = document.body.getElementsByTagName('a');
|
||
for(var i = 0;i < a.length;i++){
|
||
if(a[i].getAttribute('sc')) {
|
||
a[i].setAttribute('mid', hash(a[i].href));
|
||
a[i].onmousedown = function() {toGetForbiddenFormulaFIds();};
|
||
}
|
||
}
|
||
var btn = document.body.getElementsByTagName('button');
|
||
for(var i = 0;i < btn.length;i++){
|
||
if(btn[i].getAttribute('sc')) {
|
||
btn[i].setAttribute('mid', hash(btn[i].id));
|
||
btn[i].onmousedown = function() {toGetForbiddenFormulaFIds();};
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
<!--{/if}-->
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_viewthread_postbottom_output() {
|
||
}
|
||
<!--{block return}-->
|
||
<div id="relate_subject"></div>
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_forumdisplay_threadtype_extra_output($recwords) {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<style>
|
||
.sort_ttp { padding-top: 0;margin-bottom:5px;}
|
||
.sort_tit { padding:4px 8px 3px 0; color:#999; }
|
||
.loadingCloud { text-align:center;line-height:50px; }
|
||
</style>
|
||
<script>
|
||
var currentKeyword = '';
|
||
var currentOrder = '';
|
||
function switchkeyword(keyword, order, page) {
|
||
page = page ? page : 1;
|
||
order = order ? order : '';
|
||
if (currentKeyword == keyword && order == '' && page == 1) {
|
||
window.location = 'forum.php?mod=forumdisplay&fid={$_G[fid]}';
|
||
return true;
|
||
}
|
||
if (currentKeyword != '') {
|
||
$("ckw_"+currentKeyword).className = '';
|
||
}
|
||
$("ckw_"+keyword).className = 'xw1 a';
|
||
currentKeyword = keyword;
|
||
currentOrder = order;
|
||
getclouddata(keyword, order, page);
|
||
}
|
||
function switchPage(page) {
|
||
getclouddata(currentKeyword, currentOrder, page);
|
||
}
|
||
function switchOrder(order) {
|
||
currentOrder = order;
|
||
getclouddata(currentKeyword, order, 1);
|
||
}
|
||
function getclouddata(keyword, order, page) {
|
||
$("threadlist").innerHTML = '<div class="loadingCloud"><img src="{IMGDIR}/loading.gif" alt="loading..." class="vm" /> {lang cloudsearch:loading}</div>';
|
||
ajaxget('forum.php?mod=forumdisplay&fid={$_G[fid]}&cloudop=relatedthread&page='+page+'&of='+order+'&keyword='+keyword);
|
||
}
|
||
function succeedhandle_getRelatedData(url, msg, data) {
|
||
if(data['threaddiv']) {
|
||
$("threadlist").innerHTML = data['threaddiv'];
|
||
$("fd_page_top").innerHTML = $("fd_page_bottom").innerHTML = data['page'];
|
||
}
|
||
}
|
||
function errorhandle_getRelatedData(msg, data) {
|
||
showError(msg);
|
||
}
|
||
</script>
|
||
<ul class="ttp cl" id="thread_types2" style="padding-top:0px;">
|
||
<li class="sort_tit">{lang cloudsearch:hottopic}</li>
|
||
<!--{loop $recwords $keyword}-->
|
||
<li id="ckw_$keyword[0]"><a href="javascript:void(0);return false;" onclick="switchkeyword('$keyword[0]');">$keyword[0]</a></li>
|
||
<!--{/loop}-->
|
||
</ul>
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_forumdisplay_threadtype_inner_output() {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<style>
|
||
.sort_tit { padding:4px 8px 3px 0; color:#999; }
|
||
</style>
|
||
<li class="sort_tit">{lang cloudsearch:thread_class}</li>
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_collection_viewoptions_output() {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<a href="forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}&op=related" class="xi2">{lang cloudsearch:realtedthread}</a>
|
||
<span class="pipe">|</span>
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_collection_relatedop_output($threadlist, $multipage) {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
|
||
<ul class="ttp bm cl cttp">
|
||
<li{if !$_GET['keyword']} class="xw1 a"{/if}>
|
||
<a href="forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}&op=related" class="xi2">{$_G['collection']['name']}</a>
|
||
</li>
|
||
<!--{loop $_G['collection']['arraykeyword'] $kid $unique_keyword}-->
|
||
<li{if $unique_keyword == $_GET['keyword']} class="xw1 a"{/if}>
|
||
<a href="forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}&op=related&keyword={$_G['collection']['urlkeyword'][$kid]}" class="xi2">$unique_keyword</a>
|
||
</li>
|
||
<!--{/loop}-->
|
||
</ul>
|
||
<div class="tl bm">
|
||
<!--{if $threadlist}-->
|
||
<form action="forum.php?mod=collection&action=edit&op=addthread" method="POST">
|
||
<div class="th">
|
||
<table cellspacing="0" cellpadding="0">
|
||
<tr>
|
||
<td class="icn"></td>
|
||
<td class="o"><label class="z" onclick="checkall(this.form, 'tids')"><input class="pc" type="checkbox" name="chkall" title="{lang checkall}" /></label></td>
|
||
<td class="common">{lang thread}</td>
|
||
<td class="forum">{lang cloudsearch:forum}</td>
|
||
<td class="by">{lang author}</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="bm_c">
|
||
<table cellspacing="0" cellpadding="0">
|
||
<!--{loop $threadlist $thread}-->
|
||
<tr>
|
||
<td class="icn">
|
||
<!--{if $thread[icon]}-->
|
||
<img src="{$thread[icon]}" />
|
||
<!--{else}-->
|
||
<img src="{IMGDIR}/folder_common.gif" />
|
||
<!--{/if}-->
|
||
</td>
|
||
<td class="o">
|
||
<!--{if !isset($thread[icon])}-->
|
||
<input type="checkbox" value="$thread[tThreadId]" name="tids[]" />
|
||
<!--{/if}-->
|
||
</td>
|
||
<th>
|
||
<!--{if !isset($thread[icon])}-->
|
||
<a href="forum.php?mod=viewthread&tid=$thread[tThreadId]" target="_blank" class="xst">$thread['pSubject']</a>
|
||
<!--{else}-->
|
||
<a href="$thread['mTargetUrl']" target="_blank" class="xst">$thread['mTitle']</a>
|
||
<!--{/if}-->
|
||
</th>
|
||
<td class="forum">
|
||
<!--{if !isset($thread[icon])}-->
|
||
<a href="forum.php?mod=forumdisplay&fid=$thread[pForumId]">$thread[pForumName]</a>
|
||
<!--{else}-->
|
||
$thread[mShowUrl]
|
||
<!--{/if}-->
|
||
</td>
|
||
<td class="by">
|
||
<cite>
|
||
<!--{if $thread['pAuthorId'] && $thread['pAuthorName']}-->
|
||
<a href="home.php?mod=space&uid=$thread[pAuthorId]">$thread[pAuthorName]</a>
|
||
<!--{else}-->
|
||
{lang anonymous}
|
||
<!--{/if}-->
|
||
</cite>
|
||
<!--{if !isset($thread[icon])}-->
|
||
<em class="xi1">$thread[dateline]</em>
|
||
<!--{/if}-->
|
||
</td>
|
||
</tr>
|
||
<!--{/loop}-->
|
||
</table>
|
||
</div>
|
||
|
||
<div class="bm_c cl">
|
||
<input type="hidden" value="{$_G['collection']['ctid']}" name="ctid" />
|
||
<input type="hidden" name="formhash" id="formhash" value="{FORMHASH}" />
|
||
<input type="hidden" name="addthread" id="addthread" value="1" />
|
||
<button type="submit" class="pn pnc"><span>{lang cloudsearch:addtocollection}</span></button>
|
||
</div>
|
||
</form>
|
||
<!--{else}-->
|
||
<p class="emp">
|
||
{lang cloudsearch:no_content}
|
||
</p>
|
||
<!--{/if}-->
|
||
</div>
|
||
<!--{if $multipage}--><div class="pgs mtm cl">$multipage</div><!--{/if}-->
|
||
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_relate_threadlist_output($kw) {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<div id="cloudsearch_relate"><img src="{IMGDIR}/loading.gif" alt="loading..." class="vm" /> {lang cloudsearch:loading}</div>
|
||
<script>
|
||
ajaxget('plugin.php?id=cloudsearch:forumdisplay&cloudop=relatelist&fid={$_G['fid']}&keyword={$kw}&page={$_G['page']}', 'cloudsearch_relate');
|
||
</script>
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_relate_threadlist_js_output($relatethreadlist, $urlkw, $searchparams, $srchotquery) {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<!--{if $relatethreadlist}-->
|
||
<div class="th">
|
||
<table cellspacing="0" cellpadding="0">
|
||
<tr>
|
||
<td class="icn"></td>
|
||
<td class="common">{lang cloudsearch:relate}</td>
|
||
<td class="by">{lang cloudsearch:forum}</td>
|
||
<td class="by">{lang author}</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="bm_c">
|
||
<table cellspacing="0" cellpadding="0">
|
||
<!--{loop $relatethreadlist $thread}-->
|
||
<tbody id="$thread[id]">
|
||
<tr>
|
||
<td class="icn">
|
||
<!--{if $thread[icon]}-->
|
||
<img src="{$thread[icon]}" />
|
||
<!--{else}-->
|
||
<img src="{IMGDIR}/folder_common.gif" />
|
||
<!--{/if}-->
|
||
</td>
|
||
<th>
|
||
<!--{if !isset($thread[icon])}-->
|
||
<a href="forum.php?mod=viewthread&tid=$thread[tThreadId]" target="_blank" class="xst">$thread['pSubject']</a>
|
||
<!--{else}-->
|
||
<a href="$thread['mTargetUrl']" target="_blank" class="xst">$thread['mTitle']</a>
|
||
<!--{/if}-->
|
||
</th>
|
||
<td class="by">
|
||
<!--{if !isset($thread[icon])}-->
|
||
<a href="forum.php?mod=forumdisplay&fid=$thread[pForumId]">$thread[pForumName]</a>
|
||
<!--{else}-->
|
||
$thread[mShowUrl]
|
||
<!--{/if}-->
|
||
</td>
|
||
<td class="by">
|
||
<cite>
|
||
<!--{if $thread['pAuthorId'] && $thread['pAuthorName']}-->
|
||
<a href="home.php?mod=space&uid=$thread[pAuthorId]">$thread[pAuthorName]</a>
|
||
<!--{else}-->
|
||
{lang anonymous}
|
||
<!--{/if}-->
|
||
</cite>
|
||
<!--{if !isset($thread[icon])}-->
|
||
<em class="xi1">$thread[dateline]</em>
|
||
<!--{/if}-->
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
<!--{/loop}-->
|
||
<tr>
|
||
<td colspan="4" align="center" style="line-height:25px;">
|
||
<a href="$searchparams[url]?q={$urlkw}&source=word.tao_more.a$srchotquery">{lang cloudsearch:viewmore}</a>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<!--{/if}-->
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_global_footer_related() {
|
||
global $_G;
|
||
$rel_title = urlencode($_G['forum_thread']['subject']);
|
||
$widthauto = widthauto();
|
||
$get_reltid = dintval($_GET[reltid]);
|
||
$get_pre_pos = dhtmlspecialchars(trim($_GET[pre_pos]));
|
||
}
|
||
<!--{block return}-->
|
||
<!--{if empty($_G['inajax'])}-->
|
||
<script type="text/javascript">
|
||
var rel_tid = "$_G['tid']";
|
||
var rel_title = "$rel_title";
|
||
var rel_reltid = "$get_reltid";
|
||
var rel_prepos = "$get_pre_pos";
|
||
var my_siteid = "$_G['setting']['my_siteid']";
|
||
var rel_uid = "$_G['uid']";
|
||
var rel_views = "$_G['forum_thread']['views']";
|
||
var rel_replies = "$_G['forum_thread']['replies']";
|
||
var rel_page = "$_G['page']";
|
||
var rel_show = "$widthauto";
|
||
</script>
|
||
<script type="text/javascript" src="http://cache.soso.com/30d/js/discuz/relate_subject.js" charset="GBK"></script>
|
||
<!--{/if}-->
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_global_footer_mini() {
|
||
global $_G;
|
||
$utilService = Cloud::loadClass('Service_Util');
|
||
$params = array(
|
||
's_site_gid' => $_G['groupid'],
|
||
'response_type' => 'JSONP',
|
||
);
|
||
$params = $utilService->generateSiteSignUrl($params, false, true);
|
||
$signUrlParams = json_encode($params);
|
||
$discuz_mini_js_url = 'http://discuz.gtimg.cn/search/scripts/discuz_mini.js';
|
||
$referer = htmlspecialchars($_SERVER['HTTP_REFERER']);
|
||
}
|
||
<!--{block return}-->
|
||
<!--{if empty($_GET['inajax'])}-->
|
||
<script type="text/javascript" charset="utf-8" src="$discuz_mini_js_url"></script>
|
||
<script type="text/javascript" charset="utf-8">
|
||
if (typeof DiscuzMini != 'undefined' && typeof DiscuzMini == 'object') {
|
||
DiscuzMini.showMini('$referer', $signUrlParams);
|
||
}
|
||
</script>
|
||
<!--{/if}-->
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_index_forum_extra_output($forum_recwords) {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<!--{if $forum_recwords}-->
|
||
<dd class="fl_g_hot">
|
||
<strong>{lang cloudsearch:forumhottopic}: </strong>
|
||
<!--{loop $forum_recwords $k $frecword}--><a class="xi2" href="$frecword[url]" target="_blank">$frecword[word]</a><!--{/loop}-->
|
||
</dd>
|
||
<!--{/if}-->
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
|
||
function tpl_cloudsearch_global_footer_suggest($queryString) {
|
||
global $_G;
|
||
}
|
||
<!--{block return}-->
|
||
<script type="text/javascript">
|
||
var cloudsearch_suggest = {};
|
||
cloudsearch_suggest.cache = {}; // 缓存
|
||
cloudsearch_suggest.sId = "$_G['setting']['my_siteid']";
|
||
cloudsearch_suggest.keyInterval = null; // 按住上下键时的setTimeout时间值
|
||
cloudsearch_suggest.requestTimeout = null; // 发送jsonp请求时的setTimeout时间值
|
||
cloudsearch_suggest.responseTimeout = null; // jsonp请求超时时的setTimeout时间值
|
||
cloudsearch_suggest.slideSpeed = 700; // 按住上下键时的滚动速度
|
||
cloudsearch_suggest.linenow = 0; // 当前所在行
|
||
cloudsearch_suggest.queryString = "$queryString"; // 当前所在行
|
||
|
||
function cloudsearch_suggest_preventEnter(oEvent) {
|
||
|
||
var code = oEvent.keyCode;
|
||
var lines = $('sg').getElementsByTagName('li');
|
||
|
||
if ((38 == code || 40 == code) && !cloudsearch_suggest.keyInterval) {
|
||
cloudsearch_suggest_moveOneStep(code, lines);
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_moveOneStep(code, lines) {
|
||
|
||
if (38 == code || 40 == code) {
|
||
var panel = $('sg');
|
||
if ('block' == panel.style.display) {
|
||
|
||
cloudsearch_suggest_clearStyle(); // 清掉所有li的选中状态
|
||
var suggestNum = lines.length;
|
||
|
||
if (38 == code) {
|
||
if (cloudsearch_suggest.linenow > 1) {
|
||
cloudsearch_suggest.linenow--;
|
||
} else {
|
||
cloudsearch_suggest.linenow = suggestNum;
|
||
}
|
||
}
|
||
|
||
if (40 == code) {
|
||
cloudsearch_suggest.linenow = (cloudsearch_suggest.linenow == suggestNum) ? 1 : (cloudsearch_suggest.linenow + 1);
|
||
}
|
||
lines[cloudsearch_suggest.linenow - 1].className = 'smo';
|
||
}
|
||
|
||
cloudsearch_suggest.keyInterval = setTimeout(function() {cloudsearch_suggest_moveOneStep(code, lines);}, cloudsearch_suggest.slideSpeed);
|
||
cloudsearch_suggest.slideSpeed = 80;
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_suggest(oEvent) {
|
||
|
||
var q = trim($('scbar_txt').value); // 输入框的输入
|
||
|
||
var code = oEvent.keyCode; // 键盘按键值
|
||
var lines = $('sg').getElementsByTagName('li');
|
||
|
||
if (38 == code || 40 == code) { // up down
|
||
if (null != cloudsearch_suggest.keyInterval) {
|
||
clearTimeout(cloudsearch_suggest.keyInterval);
|
||
cloudsearch_suggest.keyInterval = null;
|
||
cloudsearch_suggest.slideSpeed = 700;
|
||
}
|
||
// 把所选值放入输入框(去除html标签)
|
||
$('scbar_txt').value = lines[cloudsearch_suggest.linenow - 1].innerHTML.replace(/<\s*(\/)?\s*[0-9a-zA-Z]+\s*>/g, '');
|
||
} else if (27 == code) { // ESC
|
||
|
||
if (null != cloudsearch_suggest.requestTimeout) {
|
||
clearTimeout(cloudsearch_suggest.requestTimeout);
|
||
}
|
||
|
||
cloudsearch_suggest_hide();
|
||
} else {
|
||
if ('' != q) {
|
||
var data = cloudsearch_suggest_getCache(q);
|
||
if (data) {
|
||
cloudsearch_suggest_menuMaker(data);
|
||
} else {
|
||
if (null != cloudsearch_suggest.requestTimeout) {
|
||
clearTimeout(cloudsearch_suggest.requestTimeout);
|
||
}
|
||
// 请求延时0.3秒执行,因为有可能用户是在持续输入
|
||
cloudsearch_suggest.requestTimeout = setTimeout(function() {cloudsearch_suggest_sendRequest(q);}, 500);
|
||
}
|
||
} else {
|
||
|
||
if (null != cloudsearch_suggest.requestTimeout) {
|
||
clearTimeout(cloudsearch_suggest.requestTimeout);
|
||
}
|
||
|
||
cloudsearch_suggest_hide();
|
||
}
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_sendRequest(q) {
|
||
|
||
// 删掉之前的请求(包括超时处理)
|
||
if ($('cloudsearch_suggest') != null) {
|
||
document.getElementsByTagName('head')[0].removeChild($('cloudsearch_suggest'));
|
||
if (null != cloudsearch_suggest.responseTimeout) {
|
||
clearTimeout(cloudsearch_suggest.responseTimeout);
|
||
}
|
||
}
|
||
|
||
var script = document.createElement('script');
|
||
with (script) {
|
||
src = 'http://search.discuz.qq.com/api/suggest?q=' + encodeURIComponent(q) + '&' + cloudsearch_suggest.queryString;
|
||
id = 'cloudsearch_suggest';
|
||
charset = 'utf-8';
|
||
}
|
||
|
||
document.getElementsByTagName('head')[0].appendChild(script); // jsonp加载外域接口数据
|
||
cloudsearch_suggest.responseTimeout = setTimeout(function() {cloudsearch_suggest_clearRequest();}, 1000); // 0.5秒后没返回就抛弃
|
||
}
|
||
|
||
function cloudsearch_suggest_clearRequest() {
|
||
// 删掉之前的请求(包括超时处理)
|
||
if ($('cloudsearch_suggest') != null) {
|
||
document.getElementsByTagName('head')[0].removeChild($('cloudsearch_suggest'));
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_callback(data) {
|
||
|
||
if (typeof data != undefined && 0 == data.status) {
|
||
|
||
cloudsearch_suggest_menuMaker(data.result);
|
||
|
||
cloudsearch_suggest_setCache(data.q, data.result);
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_menuMaker(data) {
|
||
|
||
if (data.length > 0) {
|
||
|
||
var list = '<ul>';
|
||
for (var i = 0; i < data.length; i++) {
|
||
list += '<li class="sml" onmouseover="cloudsearch_suggest_mouseOver(this);" onclick="cloudsearch_suggest_mouseClick(this);">' + data[i] + '</li>';
|
||
}
|
||
list += '</ul>';
|
||
$('st_box').innerHTML = list;
|
||
|
||
cloudsearch_suggest_show();
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_mouseClick(obj) {
|
||
$('scbar_txt').value = obj.innerHTML.replace(/<\s*(\/)?\s*[0-9a-zA-Z]+\s*>/g, '');
|
||
$('scbar_btn').click();
|
||
}
|
||
|
||
function cloudsearch_suggest_mouseOver(obj) {
|
||
cloudsearch_suggest_clearStyle(); // 清掉之前的选中状态
|
||
obj.className = "smo"; // 当前的li设置为选中状态
|
||
|
||
// 把linenow设置为当前悬停的值
|
||
var lis = $('st_box').getElementsByTagName('li');
|
||
if (typeof lis != undefined && lis.length > 0) {
|
||
for (var i = 0; i < lis.length; i++) {
|
||
if (lis[i] == obj) {
|
||
cloudsearch_suggest.linenow = i + 1;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_show(oEvent) {
|
||
cloudsearch_suggest.linenow = 0;
|
||
cloudsearch_suggest.slideSpeed = 700;
|
||
$('sg').style.display = 'block';
|
||
$('scbar_txt').focus();
|
||
}
|
||
|
||
function cloudsearch_suggest_hide() {
|
||
$('sg').style.display = 'none';
|
||
}
|
||
|
||
function cloudsearch_suggest_setCache(key, data) {
|
||
cloudsearch_suggest.cache[key] = data;
|
||
}
|
||
|
||
function cloudsearch_suggest_getCache(key) {
|
||
return cloudsearch_suggest.cache[key];
|
||
}
|
||
|
||
function cloudsearch_suggest_clearStyle() {
|
||
var lis = $('st_box').getElementsByTagName('li');
|
||
if (typeof lis != undefined && lis.length > 0) {
|
||
for (var i = 0; i < lis.length; i++) {
|
||
lis[i].className = 'sml';
|
||
}
|
||
}
|
||
}
|
||
|
||
function cloudsearch_suggest_sgMouseOver() {
|
||
$('scbar_txt').focus();
|
||
_detachEvent($('scbar_txt'), 'blur', cloudsearch_suggest_hide);
|
||
}
|
||
|
||
function cloudsearch_suggest_sgMouseOut() {
|
||
cloudsearch_suggest_clearStyle();
|
||
_attachEvent($('scbar_txt'), 'blur', cloudsearch_suggest_hide);
|
||
}
|
||
|
||
if (!BROWSER.ie || BROWSER.ie > 6) {
|
||
// 输入框绑定onkeydown和onkeyup事件
|
||
_attachEvent($('scbar_txt'), 'keydown', cloudsearch_suggest_preventEnter);
|
||
_attachEvent($('scbar_txt'), 'keyup', cloudsearch_suggest_suggest);
|
||
_attachEvent($('scbar_txt'), 'blur', cloudsearch_suggest_hide);
|
||
_attachEvent($('sg'), 'mouseover', cloudsearch_suggest_sgMouseOver);
|
||
_attachEvent($('sg'), 'mouseout', cloudsearch_suggest_sgMouseOut);
|
||
}
|
||
</script>
|
||
<!--{/block}-->
|
||
<!--{eval return $return;}-->
|
||
{eval
|
||
}
|
||
} |