PageRenderTime 55ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/source/plugin/cloudsearch/template/module.htm

https://github.com/kuaileshike/upload
HTML | 652 lines | 494 code | 59 blank | 99 comment | 0 complexity | fb4fc894d68e6bc25d3d7ac876d9ed8b MD5 | raw file
  1. {eval
  2. function tpl_cloudsearch_index_top($recwords, $searchparams, $srchotquery, $position = 'hotopicf') {
  3. global $_G;
  4. if($recwords) {
  5. $recwords_tmp = $recwords;
  6. $recwords = array();
  7. foreach ($recwords_tmp as $k => $v) {
  8. $recwords[$k+1] = $v;
  9. }{eval }}{eval }}
  10. <!--{block return}-->
  11. <!--{if is_array($recwords) && count($recwords) > 0 && !empty($searchparams[url])}-->
  12. <div class="fl bm">
  13. <div class="bm bmw hottopic cl">
  14. <div class="bm_h cl">
  15. <span class="y"></span>
  16. <h2>{if $_G['fid']}{lang cloudsearch:current}{/if}{lang cloudsearch:hottopic}</h2>
  17. </div>
  18. <style>
  19. .filter { padding: 10px; border-bottom: none; font-size: 12px; color: #999; }
  20. .filter ul {}
  21. .filter li { float: left; margin-right: 16px; height: 22px; line-height: 22px; white-space:nowrap; width:12.5%; }
  22. .filter li a { margin-right: 2px; text-decoration: none; color: #369; }
  23. .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; }
  24. .filter li a:hover { text-decoration: underline; }
  25. .filter li a:visited { text-decoration: none; color: #666; }
  26. .filter li.clewcolor a:visited { text-decoration: none; color: #F00; }
  27. .filter .number { color: #666; }
  28. .filter li.clewcolor .number { color:#F00; }
  29. </style>
  30. <div class="filter">
  31. <ul class="cl">
  32. <!--{loop $recwords $key $recword}-->
  33. <!--{if $encodeWord=rawurlencode(trim($recword[word]))}-->
  34. <!--{if empty($recword[inc_num])}-->
  35. <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>
  36. <!--{else}-->
  37. <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>
  38. <!--{/if}-->
  39. <!--{/if}-->
  40. <!--{/loop}-->
  41. </ul>
  42. </div>
  43. </div>
  44. </div>
  45. <!--{/if}-->
  46. <!--{/block}-->
  47. <!--{eval return $return;}-->
  48. {eval
  49. }
  50. function tpl_cloudsearch_global_footer_formula_output() {
  51. global $_G;
  52. $formHash = FORMHASH;
  53. $cookie = $_G['cookie']['ffids' . $_G['uid']];
  54. }
  55. <!--{block return}-->
  56. <!--{if !$cookie}-->
  57. <script type="text/javascript">
  58. _attachEvent(window, 'load', getForbiddenFormula, document);
  59. function getForbiddenFormula() {
  60. var toGetForbiddenFormulaFIds = function () {
  61. ajaxget('plugin.php?id=cloudsearch&formhash={$formHash}');
  62. };
  63. var a = document.body.getElementsByTagName('a');
  64. for(var i = 0;i < a.length;i++){
  65. if(a[i].getAttribute('sc')) {
  66. a[i].setAttribute('mid', hash(a[i].href));
  67. a[i].onmousedown = function() {toGetForbiddenFormulaFIds();};
  68. }
  69. }
  70. var btn = document.body.getElementsByTagName('button');
  71. for(var i = 0;i < btn.length;i++){
  72. if(btn[i].getAttribute('sc')) {
  73. btn[i].setAttribute('mid', hash(btn[i].id));
  74. btn[i].onmousedown = function() {toGetForbiddenFormulaFIds();};
  75. }
  76. }
  77. }
  78. </script>
  79. <!--{/if}-->
  80. <!--{/block}-->
  81. <!--{eval return $return;}-->
  82. {eval
  83. }
  84. function tpl_cloudsearch_viewthread_modaction_output() {
  85. }
  86. <!--{block return}-->
  87. <div id="relate_subject"></div>
  88. <!--{/block}-->
  89. <!--{eval return $return;}-->
  90. {eval
  91. }
  92. function tpl_cloudsearch_forumdisplay_threadtype_extra_output($recwords) {
  93. global $_G;
  94. }
  95. <!--{block return}-->
  96. <style>
  97. .sort_ttp { padding-top: 0;margin-bottom:5px;}
  98. .sort_tit { padding:4px 8px 3px 0; color:#999; }
  99. .loadingCloud { text-align:center;line-height:50px; }
  100. </style>
  101. <script>
  102. var currentKeyword = '';
  103. var currentOrder = '';
  104. function switchkeyword(keyword, order, page) {
  105. page = page ? page : 1;
  106. order = order ? order : '';
  107. if (currentKeyword == keyword && order == '' && page == 1) {
  108. window.location = 'forum.php?mod=forumdisplay&fid={$_G[fid]}';
  109. return true;
  110. }
  111. if (currentKeyword != '') {
  112. $("ckw_"+currentKeyword).className = '';
  113. }
  114. $("ckw_"+keyword).className = 'xw1 a';
  115. currentKeyword = keyword;
  116. currentOrder = order;
  117. getclouddata(keyword, order, page);
  118. }
  119. function switchPage(page) {
  120. getclouddata(currentKeyword, currentOrder, page);
  121. }
  122. function switchOrder(order) {
  123. currentOrder = order;
  124. getclouddata(currentKeyword, order, 1);
  125. }
  126. function getclouddata(keyword, order, page) {
  127. $("threadlist").innerHTML = '<div class="loadingCloud"><img src="{IMGDIR}/loading.gif" alt="loading..." class="vm" /> {lang cloudsearch:loading}</div>';
  128. ajaxget('forum.php?mod=forumdisplay&fid={$_G[fid]}&cloudop=relatedthread&page='+page+'&of='+order+'&keyword='+keyword);
  129. }
  130. function succeedhandle_getRelatedData(url, msg, data) {
  131. if(data['threaddiv']) {
  132. $("threadlist").innerHTML = data['threaddiv'];
  133. $("fd_page_top").innerHTML = $("fd_page_bottom").innerHTML = data['page'];
  134. }
  135. }
  136. function errorhandle_getRelatedData(msg, data) {
  137. showError(msg);
  138. }
  139. </script>
  140. <ul class="ttp cl" id="thread_types2" style="padding-top:0px;">
  141. <li class="sort_tit">{lang cloudsearch:hottopic}</li>
  142. <!--{loop $recwords $keyword}-->
  143. <li id="ckw_$keyword[0]"><a href="javascript:void(0);return false;" onclick="switchkeyword('$keyword[0]');">$keyword[0]</a></li>
  144. <!--{/loop}-->
  145. </ul>
  146. <!--{/block}-->
  147. <!--{eval return $return;}-->
  148. {eval
  149. }
  150. function tpl_cloudsearch_forumdisplay_threadtype_inner_output() {
  151. global $_G;
  152. }
  153. <!--{block return}-->
  154. <style>
  155. .sort_tit { padding:4px 8px 3px 0; color:#999; }
  156. </style>
  157. <li class="sort_tit">{lang cloudsearch:thread_class}</li>
  158. <!--{/block}-->
  159. <!--{eval return $return;}-->
  160. {eval
  161. }
  162. function tpl_cloudsearch_collection_viewoptions_output() {
  163. global $_G;
  164. }
  165. <!--{block return}-->
  166. <a href="forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}&op=related" class="xi2">{lang cloudsearch:realtedthread}</a>
  167. <span class="pipe">|</span>
  168. <!--{/block}-->
  169. <!--{eval return $return;}-->
  170. {eval
  171. }
  172. function tpl_cloudsearch_collection_relatedop_output($threadlist, $multipage) {
  173. global $_G;
  174. }
  175. <!--{block return}-->
  176. <ul class="ttp bm cl cttp">
  177. <li{if !$_GET['keyword']} class="xw1 a"{/if}>
  178. <a href="forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}&op=related" class="xi2">{$_G['collection']['name']}</a>
  179. </li>
  180. <!--{loop $_G['collection']['arraykeyword'] $kid $unique_keyword}-->
  181. <li{if $unique_keyword == $_GET['keyword']} class="xw1 a"{/if}>
  182. <a href="forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}&op=related&keyword={$_G['collection']['urlkeyword'][$kid]}" class="xi2">$unique_keyword</a>
  183. </li>
  184. <!--{/loop}-->
  185. </ul>
  186. <div class="tl bm">
  187. <!--{if $threadlist}-->
  188. <form action="forum.php?mod=collection&action=edit&op=addthread" method="POST">
  189. <div class="th">
  190. <table cellspacing="0" cellpadding="0">
  191. <tr>
  192. <td class="icn"></td>
  193. <td class="o"><label class="z" onclick="checkall(this.form, 'tids')"><input class="pc" type="checkbox" name="chkall" title="{lang checkall}" /></label></td>
  194. <td class="common">{lang thread}</td>
  195. <td class="forum">{lang cloudsearch:forum}</td>
  196. <td class="by">{lang author}</td>
  197. </tr>
  198. </table>
  199. </div>
  200. <div class="bm_c">
  201. <table cellspacing="0" cellpadding="0">
  202. <!--{loop $threadlist $thread}-->
  203. <tr>
  204. <td class="icn">
  205. <!--{if $thread[icon]}-->
  206. <img src="{$thread[icon]}" />
  207. <!--{else}-->
  208. <img src="{IMGDIR}/folder_common.gif" />
  209. <!--{/if}-->
  210. </td>
  211. <td class="o">
  212. <!--{if !isset($thread[icon])}-->
  213. <input type="checkbox" value="$thread[tThreadId]" name="tids[]" />
  214. <!--{/if}-->
  215. </td>
  216. <th>
  217. <!--{if !isset($thread[icon])}-->
  218. <a href="forum.php?mod=viewthread&tid=$thread[tThreadId]" target="_blank" class="xst">$thread['pSubject']</a>
  219. <!--{else}-->
  220. <a href="$thread['mTargetUrl']" target="_blank" class="xst">$thread['mTitle']</a>
  221. <!--{/if}-->
  222. </th>
  223. <td class="forum">
  224. <!--{if !isset($thread[icon])}-->
  225. <a href="forum.php?mod=forumdisplay&fid=$thread[pForumId]">$thread[pForumName]</a>
  226. <!--{else}-->
  227. $thread[mShowUrl]
  228. <!--{/if}-->
  229. </td>
  230. <td class="by">
  231. <cite>
  232. <!--{if $thread['pAuthorId'] && $thread['pAuthorName']}-->
  233. <a href="home.php?mod=space&uid=$thread[pAuthorId]">$thread[pAuthorName]</a>
  234. <!--{else}-->
  235. {lang anonymous}
  236. <!--{/if}-->
  237. </cite>
  238. <!--{if !isset($thread[icon])}-->
  239. <em class="xi1">$thread[dateline]</em>
  240. <!--{/if}-->
  241. </td>
  242. </tr>
  243. <!--{/loop}-->
  244. </table>
  245. </div>
  246. <div class="bm_c cl">
  247. <input type="hidden" value="{$_G['collection']['ctid']}" name="ctid" />
  248. <input type="hidden" name="formhash" id="formhash" value="{FORMHASH}" />
  249. <input type="hidden" name="addthread" id="addthread" value="1" />
  250. <button type="submit" class="pn pnc"><span>{lang cloudsearch:addtocollection}</span></button>
  251. </div>
  252. </form>
  253. <!--{else}-->
  254. <p class="emp">
  255. {lang cloudsearch:no_content}
  256. </p>
  257. <!--{/if}-->
  258. </div>
  259. <!--{if $multipage}--><div class="pgs mtm cl">$multipage</div><!--{/if}-->
  260. <!--{/block}-->
  261. <!--{eval return $return;}-->
  262. {eval
  263. }
  264. function tpl_cloudsearch_relate_threadlist_output($kw) {
  265. global $_G;
  266. }
  267. <!--{block return}-->
  268. <div id="cloudsearch_relate"><img src="{IMGDIR}/loading.gif" alt="loading..." class="vm" /> {lang cloudsearch:loading}</div>
  269. <script>
  270. ajaxget('plugin.php?id=cloudsearch:forumdisplay&cloudop=relatelist&fid={$_G['fid']}&keyword={$kw}&page={$_G['page']}', 'cloudsearch_relate');
  271. </script>
  272. <!--{/block}-->
  273. <!--{eval return $return;}-->
  274. {eval
  275. }
  276. function tpl_cloudsearch_relate_threadlist_js_output($relatethreadlist, $urlkw, $searchparams, $srchotquery) {
  277. global $_G;
  278. }
  279. <!--{block return}-->
  280. <!--{if $relatethreadlist}-->
  281. <div class="th">
  282. <table cellspacing="0" cellpadding="0">
  283. <tr>
  284. <td class="icn"></td>
  285. <td class="common">{lang cloudsearch:relate}</td>
  286. <td class="by">{lang cloudsearch:forum}</td>
  287. <td class="by">{lang author}</td>
  288. </tr>
  289. </table>
  290. </div>
  291. <div class="bm_c">
  292. <table cellspacing="0" cellpadding="0">
  293. <!--{loop $relatethreadlist $thread}-->
  294. <tbody id="$thread[id]">
  295. <tr>
  296. <td class="icn">
  297. <!--{if $thread[icon]}-->
  298. <img src="{$thread[icon]}" />
  299. <!--{else}-->
  300. <img src="{IMGDIR}/folder_common.gif" />
  301. <!--{/if}-->
  302. </td>
  303. <th>
  304. <!--{if !isset($thread[icon])}-->
  305. <a href="forum.php?mod=viewthread&tid=$thread[tThreadId]" target="_blank" class="xst">$thread['pSubject']</a>
  306. <!--{else}-->
  307. <a href="$thread['mTargetUrl']" target="_blank" class="xst">$thread['mTitle']</a>
  308. <!--{/if}-->
  309. </th>
  310. <td class="by">
  311. <!--{if !isset($thread[icon])}-->
  312. <a href="forum.php?mod=forumdisplay&fid=$thread[pForumId]">$thread[pForumName]</a>
  313. <!--{else}-->
  314. $thread[mShowUrl]
  315. <!--{/if}-->
  316. </td>
  317. <td class="by">
  318. <cite>
  319. <!--{if $thread['pAuthorId'] && $thread['pAuthorName']}-->
  320. <a href="home.php?mod=space&uid=$thread[pAuthorId]">$thread[pAuthorName]</a>
  321. <!--{else}-->
  322. {lang anonymous}
  323. <!--{/if}-->
  324. </cite>
  325. <!--{if !isset($thread[icon])}-->
  326. <em class="xi1">$thread[dateline]</em>
  327. <!--{/if}-->
  328. </td>
  329. </tr>
  330. </tbody>
  331. <!--{/loop}-->
  332. <tr>
  333. <td colspan="4" align="center" style="line-height:25px;">
  334. <a href="$searchparams[url]?q={$urlkw}&source=word.tao_more.a$srchotquery">{lang cloudsearch:viewmore}</a>
  335. </td>
  336. </tr>
  337. </table>
  338. </div>
  339. <!--{/if}-->
  340. <!--{/block}-->
  341. <!--{eval return $return;}-->
  342. {eval
  343. }
  344. function tpl_cloudsearch_global_footer_related() {
  345. global $_G;
  346. $rel_title = urlencode($_G['forum_thread']['subject']);
  347. $widthauto = widthauto();
  348. $get_reltid = dintval($_GET[reltid]);
  349. $get_pre_pos = dhtmlspecialchars(trim($_GET[pre_pos]));
  350. }
  351. <!--{block return}-->
  352. <!--{if empty($_G['inajax'])}-->
  353. <script type="text/javascript">
  354. var rel_tid = "$_G['tid']";
  355. var rel_title = "$rel_title";
  356. var rel_reltid = "$get_reltid";
  357. var rel_prepos = "$get_pre_pos";
  358. var my_siteid = "$_G['setting']['my_siteid']";
  359. var rel_uid = "$_G['uid']";
  360. var rel_views = "$_G['forum_thread']['views']";
  361. var rel_replies = "$_G['forum_thread']['replies']";
  362. var rel_page = "$_G['page']";
  363. var rel_show = "$widthauto";
  364. </script>
  365. <script type="text/javascript" src="http://cache.soso.com/30d/js/discuz/relate_subject.js" charset="GBK"></script>
  366. <!--{/if}-->
  367. <!--{/block}-->
  368. <!--{eval return $return;}-->
  369. {eval
  370. }
  371. function tpl_cloudsearch_global_footer_mini() {
  372. global $_G;
  373. $utilService = Cloud::loadClass('Service_Util');
  374. $params = array(
  375. 's_site_gid' => $_G['groupid'],
  376. 'response_type' => 'JSONP',
  377. );
  378. $params = $utilService->generateSiteSignUrl($params);
  379. parse_str($params, $paramArr);
  380. $signUrlParams = json_encode($paramArr);
  381. $discuz_mini_js_url = 'http://discuz.gtimg.cn/search/scripts/discuz_mini.js';
  382. $referer = htmlspecialchars($_SERVER['HTTP_REFERER']);
  383. }
  384. <!--{block return}-->
  385. <!--{if empty($_GET['inajax'])}-->
  386. <script type="text/javascript" charset="utf-8" src="$discuz_mini_js_url"></script>
  387. <script type="text/javascript" charset="utf-8">
  388. if (typeof DiscuzMini != 'undefined' && typeof DiscuzMini == 'object') {
  389. DiscuzMini.showMini('$referer', $signUrlParams);
  390. }
  391. </script>
  392. <!--{/if}-->
  393. <!--{/block}-->
  394. <!--{eval return $return;}-->
  395. {eval
  396. }
  397. function tpl_index_forum_extra_output($forum_recwords) {
  398. global $_G;
  399. }
  400. <!--{block return}-->
  401. <!--{if $forum_recwords}-->
  402. <dd class="fl_g_hot">
  403. <strong>{lang cloudsearch:forumhottopic}: </strong>
  404. <!--{loop $forum_recwords $k $frecword}--><a class="xi2" href="$frecword[url]" target="_blank">$frecword[word]</a><!--{/loop}-->
  405. </dd>
  406. <!--{/if}-->
  407. <!--{/block}-->
  408. <!--{eval return $return;}-->
  409. {eval
  410. }
  411. function tpl_cloudsearch_global_footer_suggest($queryString) {
  412. global $_G;
  413. }
  414. <!--{block return}-->
  415. <script type="text/javascript">
  416. var cloudsearch_suggest = {};
  417. cloudsearch_suggest.cache = {}; // 缓存
  418. cloudsearch_suggest.sId = "$_G['setting']['my_siteid']";
  419. cloudsearch_suggest.keyInterval = null; // 按住上下键时的setTimeout时间值
  420. cloudsearch_suggest.requestTimeout = null; // 发送jsonp请求时的setTimeout时间值
  421. cloudsearch_suggest.responseTimeout = null; // jsonp请求超时时的setTimeout时间值
  422. cloudsearch_suggest.slideSpeed = 700; // 按住上下键时的滚动速度
  423. cloudsearch_suggest.linenow = 0; // 当前所在行
  424. cloudsearch_suggest.queryString = "$queryString"; // 当前所在行
  425. function cloudsearch_suggest_preventEnter(oEvent) {
  426. var code = oEvent.keyCode;
  427. var lines = $('sg').getElementsByTagName('li');
  428. if ((38 == code || 40 == code) && !cloudsearch_suggest.keyInterval) {
  429. cloudsearch_suggest_moveOneStep(code, lines);
  430. }
  431. }
  432. function cloudsearch_suggest_moveOneStep(code, lines) {
  433. if (38 == code || 40 == code) {
  434. var panel = $('sg');
  435. if ('block' == panel.style.display) {
  436. cloudsearch_suggest_clearStyle(); // 清掉所有li的选中状态
  437. var suggestNum = lines.length;
  438. if (38 == code) {
  439. if (cloudsearch_suggest.linenow > 1) {
  440. cloudsearch_suggest.linenow--;
  441. } else {
  442. cloudsearch_suggest.linenow = suggestNum;
  443. }
  444. }
  445. if (40 == code) {
  446. cloudsearch_suggest.linenow = (cloudsearch_suggest.linenow == suggestNum) ? 1 : (cloudsearch_suggest.linenow + 1);
  447. }
  448. lines[cloudsearch_suggest.linenow - 1].className = 'smo';
  449. }
  450. cloudsearch_suggest.keyInterval = setTimeout(function() {cloudsearch_suggest_moveOneStep(code, lines);}, cloudsearch_suggest.slideSpeed);
  451. cloudsearch_suggest.slideSpeed = 80;
  452. }
  453. }
  454. function cloudsearch_suggest_suggest(oEvent) {
  455. var q = trim($('scbar_txt').value); // 输入框的输入
  456. var code = oEvent.keyCode; // 键盘按键值
  457. var lines = $('sg').getElementsByTagName('li');
  458. if (38 == code || 40 == code) { // up down
  459. if (null != cloudsearch_suggest.keyInterval) {
  460. clearTimeout(cloudsearch_suggest.keyInterval);
  461. cloudsearch_suggest.keyInterval = null;
  462. cloudsearch_suggest.slideSpeed = 700;
  463. }
  464. // 把所选值放入输入框(去除html标签)
  465. $('scbar_txt').value = lines[cloudsearch_suggest.linenow - 1].innerHTML.replace(/<\s*(\/)?\s*[0-9a-zA-Z]+\s*>/g, '');
  466. } else if (27 == code) { // ESC
  467. if (null != cloudsearch_suggest.requestTimeout) {
  468. clearTimeout(cloudsearch_suggest.requestTimeout);
  469. }
  470. cloudsearch_suggest_hide();
  471. } else {
  472. if ('' != q) {
  473. var data = cloudsearch_suggest_getCache(q);
  474. if (data) {
  475. cloudsearch_suggest_menuMaker(data);
  476. } else {
  477. if (null != cloudsearch_suggest.requestTimeout) {
  478. clearTimeout(cloudsearch_suggest.requestTimeout);
  479. }
  480. // 请求延时0.3秒执行,因为有可能用户是在持续输入
  481. cloudsearch_suggest.requestTimeout = setTimeout(function() {cloudsearch_suggest_sendRequest(q);}, 500);
  482. }
  483. } else {
  484. if (null != cloudsearch_suggest.requestTimeout) {
  485. clearTimeout(cloudsearch_suggest.requestTimeout);
  486. }
  487. cloudsearch_suggest_hide();
  488. }
  489. }
  490. }
  491. function cloudsearch_suggest_sendRequest(q) {
  492. // 删掉之前的请求(包括超时处理)
  493. if ($('cloudsearch_suggest') != null) {
  494. document.getElementsByTagName('head')[0].removeChild($('cloudsearch_suggest'));
  495. if (null != cloudsearch_suggest.responseTimeout) {
  496. clearTimeout(cloudsearch_suggest.responseTimeout);
  497. }
  498. }
  499. var script = document.createElement('script');
  500. with (script) {
  501. src = 'http://search.discuz.qq.com/api/suggest?q=' + encodeURIComponent(q) + '&' + cloudsearch_suggest.queryString;
  502. id = 'cloudsearch_suggest';
  503. charset = 'utf-8';
  504. }
  505. document.getElementsByTagName('head')[0].appendChild(script); // jsonp加载外域接口数据
  506. cloudsearch_suggest.responseTimeout = setTimeout(function() {cloudsearch_suggest_clearRequest();}, 1000); // 0.5秒后没返回就抛弃
  507. }
  508. function cloudsearch_suggest_clearRequest() {
  509. // 删掉之前的请求(包括超时处理)
  510. if ($('cloudsearch_suggest') != null) {
  511. document.getElementsByTagName('head')[0].removeChild($('cloudsearch_suggest'));
  512. }
  513. }
  514. function cloudsearch_suggest_callback(data) {
  515. if (typeof data != undefined && 0 == data.status) {
  516. cloudsearch_suggest_menuMaker(data.result);
  517. cloudsearch_suggest_setCache(data.q, data.result);
  518. }
  519. }
  520. function cloudsearch_suggest_menuMaker(data) {
  521. if (data.length > 0) {
  522. var list = '<ul>';
  523. for (var i = 0; i < data.length; i++) {
  524. list += '<li class="sml" onmouseover="cloudsearch_suggest_mouseOver(this);" onclick="cloudsearch_suggest_mouseClick(this);">' + data[i] + '</li>';
  525. }
  526. list += '</ul>';
  527. $('st_box').innerHTML = list;
  528. cloudsearch_suggest_show();
  529. }
  530. }
  531. function cloudsearch_suggest_mouseClick(obj) {
  532. $('scbar_txt').value = obj.innerHTML.replace(/<\s*(\/)?\s*[0-9a-zA-Z]+\s*>/g, '');
  533. $('scbar_btn').click();
  534. }
  535. function cloudsearch_suggest_mouseOver(obj) {
  536. cloudsearch_suggest_clearStyle(); // 清掉之前的选中状态
  537. obj.className = "smo"; // 当前的li设置为选中状态
  538. // 把linenow设置为当前悬停的值
  539. var lis = $('st_box').getElementsByTagName('li');
  540. if (typeof lis != undefined && lis.length > 0) {
  541. for (var i = 0; i < lis.length; i++) {
  542. if (lis[i] == obj) {
  543. cloudsearch_suggest.linenow = i + 1;
  544. break;
  545. }
  546. }
  547. }
  548. }
  549. function cloudsearch_suggest_show(oEvent) {
  550. cloudsearch_suggest.linenow = 0;
  551. cloudsearch_suggest.slideSpeed = 700;
  552. $('sg').style.display = 'block';
  553. $('scbar_txt').focus();
  554. }
  555. function cloudsearch_suggest_hide() {
  556. $('sg').style.display = 'none';
  557. }
  558. function cloudsearch_suggest_setCache(key, data) {
  559. cloudsearch_suggest.cache[key] = data;
  560. }
  561. function cloudsearch_suggest_getCache(key) {
  562. return cloudsearch_suggest.cache[key];
  563. }
  564. function cloudsearch_suggest_clearStyle() {
  565. var lis = $('st_box').getElementsByTagName('li');
  566. if (typeof lis != undefined && lis.length > 0) {
  567. for (var i = 0; i < lis.length; i++) {
  568. lis[i].className = 'sml';
  569. }
  570. }
  571. }
  572. function cloudsearch_suggest_sgMouseOver() {
  573. $('scbar_txt').focus();
  574. _detachEvent($('scbar_txt'), 'blur', cloudsearch_suggest_hide);
  575. }
  576. function cloudsearch_suggest_sgMouseOut() {
  577. cloudsearch_suggest_clearStyle();
  578. _attachEvent($('scbar_txt'), 'blur', cloudsearch_suggest_hide);
  579. }
  580. if (!BROWSER.ie || BROWSER.ie > 6) {
  581. // 输入框绑定onkeydown和onkeyup事件
  582. _attachEvent($('scbar_txt'), 'keydown', cloudsearch_suggest_preventEnter);
  583. _attachEvent($('scbar_txt'), 'keyup', cloudsearch_suggest_suggest);
  584. _attachEvent($('scbar_txt'), 'blur', cloudsearch_suggest_hide);
  585. _attachEvent($('sg'), 'mouseover', cloudsearch_suggest_sgMouseOver);
  586. _attachEvent($('sg'), 'mouseout', cloudsearch_suggest_sgMouseOut);
  587. }
  588. </script>
  589. <!--{/block}-->
  590. <!--{eval return $return;}-->
  591. {eval
  592. }
  593. }