/** PTNovelSearch-v4.1.2 LPPL License By http://www.ptcms.com/ */
 ;var PTSV={t:null,ajax:0};$ptm.search={init:function(t){t.on("keydown click",function(){$ptm.search.suggest(t)}),$(document).on("tap",".searchsuggest li,.searchhistory a",function(){var t=$(this).html();$ptm.search.go(t)}),$(".pt-search-textbtn").on("tap",function(){$ptm.search.go(t.val())}),$(document).on("tap",".searchhistroyclear",function(){$ptm.alert.open({title:"提示",content:"确认清空搜索历史么",okval:"确定",cancelval:"取消",okfunc:function(){$ptm.search.history.clear()}})}),$ptm.search.history.init()},history:{init:function(){if(list=JSON.parse(localStorage.getItem("searchlist")),list&&"object"==typeof list){var t='<dt><i class="fa fa-trash searchhistroyclear"><b>清空历史</b></i>搜索历史</dt>';$.each(list,function(a,s){t+='<dd><a class="noicon ptm-text-cut">'+s+"</a></dd>"}),$(".searchhistory").html(t)}},add:function(t){var a=[];a.push(t),list=JSON.parse(localStorage.getItem("searchlist")),list&&"object"==typeof list&&($.each(list,function(s,e){e!=t&&a.push(e)}),a.length>6&&(a=a.slice(0,6))),localStorage.setItem("searchlist",JSON.stringify(a))},clear:function(){localStorage.setItem("searchlist",JSON.stringify([]))}},go:function(t){t?($ptm.search.history.add(t),window.location=basesearchurl+encodeURIComponent(t)):$ptm.toast("关键词不能为空")},suggest:function(t){PTSV.t&&clearTimeout(PTSV.t),PTSV.t=setTimeout(function(){var a=t.val();a?$.get("/api/search/suggest.json",{key:t.val()},function(t){if(1==t.status){var a="";$.each(t.data,function(s,e){s<5&&(a+="<li>"+t.data[s]+"</li>")}),$(".searchsuggest").show().html(a)}},"json"):$(".searchsuggest").hide().html("")},200)}};