1 |
- !function(a,b){var c=this,d={},e=c.jQuery;a(c,d,e),c.csdn===b?c.csdn=d:e.extend(c.csdn,d),e.extend(c,d)}(function(global,exports,$,undefined){document.domain="csdn.net";var searchServiceReady=!1,searchArgs=[],searchService=exports.searchService=function(){var a=[].slice.call(arguments,0);searchServiceReady?searchServiceFunc.apply(null,a):searchArgs.push(a)},render=searchService.render=function(tmpl,item,data){return tmpl.replace(/#\{ +([^}]+) +\}/gm,function($0,$1){return eval("item."+$1)!==undefined&&($1="item."+$1),eval($1)})},ajaxProxyCaches={},ajaxProxy=searchService.ajaxProxy=function(a,b){var c=ajaxProxyCaches[a];if(c===undefined){c=ajaxProxyCaches[a]=[];var d=arguments.callee;$('<iframe src="'+a+'" style="display:none">').load(function(){c.contentWindow=this.contentWindow,d(a,b)}).prependTo("body")}else if(c.contentWindow===undefined)c.push(b);else do c.contentWindow.jQuery.ajax(b);while(b=c.shift())},trackingAd=function(a){"undefined"!=typeof window.csdn&&"function"==typeof window.csdn.trackingAd?window.csdn.trackingAd(a):$(document).bind("trackingAd-ready",function(){trackingAd(a)})},searchServiceFunc=function(a,b){var c="search"==a.url?'<li><a href="#{ object.url }" title="#{ object.title }">#{ object.title }</a></li>':'<li><a href="#{ url }" title="#{ title }" strategy="#{ strategy }">#{ title }</a></li>';if(a=$.extend({index:"",appendTo:"",query:"",tmpl:c,from:0,size:6,fields:["title","url"],token:"search_js_dkuyqthzbajmncbsb_token",render:render},a),a.index&&a.query){var d={};if("recommend"==a.url){var e=$.cookie("UserName")||"fake_userId",f=$.cookie("uuid_tt_dd")||"fake_uuid",g=/(\d+)$/,h=window.location.href,i=g.test(h)?RegExp.$1:"";d={userId:e,size:10,his:a.his+":"+i,client:a.client||"download_cf_enhance",query:a.query,cid:f},$.ajax({type:"GET",url:"http://recdm.csdn.net/getRecommendList.html",data:d,dataType:"jsonp",jsonp:"jsonp",success:function(c){var d=a.appendTo,e=a.tmpl;if(null===c||c.ok===!1&&c.message){var f=null!==c?c.message:"请求失败";d&&$(d).append(render('<div class="search-error">#{ item }</div>',f)),"function"==typeof b&&b(f,c,a)}else c.length>0&&(d&&($(d).append($.map(c,function(b){return a.render(e,b,c)}).join("")),trackingAd(d)),"function"==typeof b&&b(null,c,a))}})}else"search"==a.url&&($.map(["query","from","size","filter","sort","fields"],function(b){a.hasOwnProperty(b)&&(d[b]=a[b])}),ajaxProxy("http://search.api.csdn.net/proxy.html",{type:"POST",url:"http://search.api.csdn.net/"+a.index+"/csdn/_search",data:JSON.stringify(d),dataType:"json",headers:{"X-ACL-TOKEN":a.token},success:function(c){var d=a.appendTo,e=a.tmpl;if(null===c||c.ok===!1&&c.message){var f=null!==c?c.message:"请求失败";d&&$(d).append(render('<div class="search-error">#{ item }</div>',f)),"function"==typeof b&&b(f,c,a)}else c.hits&&(d&&($(d).append($.map(c.hits,function(b){return a.render(e,b,c)}).join("")),trackingAd(d)),"function"==typeof b&&b(null,c,a))}}))}};global.JSON===undefined?$.getScript("http://csdnimg.cn/rabbit/search-service/json2.js",function(){searchServiceReady=!0;for(var a;a=searchArgs.shift();)searchService.apply(null,a)}):searchServiceReady=!0});
|