198 lines
6.5 KiB
JavaScript
198 lines
6.5 KiB
JavaScript
function postcomment(){
|
|
var url="/data/postcomment";
|
|
var date = $('#postcommentform').serialize();
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url':url,
|
|
'data':date,
|
|
'success':function(html){
|
|
$('#postcomment').html('提交');
|
|
setTimeout("$('#postcomment').removeAttr('disabled');",3000);
|
|
$('#returninfo').html(html);
|
|
ajaxpage(0);
|
|
},
|
|
'beforeSend':function(){
|
|
$('#postcomment').attr('disabled','disabled');
|
|
$('#postcomment').html('<img src="/images/11887177066.gif" />正在提交...');
|
|
}
|
|
});
|
|
}
|
|
|
|
function getSubFileList(uuid,id,depth){
|
|
if($("#div_"+id).length>0)
|
|
{
|
|
$('#span_'+id).html('+');
|
|
$("#div_"+id).remove();
|
|
return false;
|
|
}
|
|
$('<div/>', {
|
|
'style':'overflow:auto;',
|
|
'id': 'div_'+id,
|
|
"html": '<li><img src="/images/loading.gif" />加载中</li>'
|
|
}).appendTo('#li_'+id);
|
|
url="/service/subfilelist/uuid/"+uuid+"/subpath/"+id+"/depth/"+depth;
|
|
$.getJSON(url, function(data) {
|
|
var items = [];
|
|
$.each(data, function(key, val) {
|
|
if(val['filename'].match(/\/$/))
|
|
{
|
|
items.push('<li id="li_' + val['id'] + '"><span id="span_'+val['id']+'">+</span> <a href="javascript:;" id="taget_'+val['id']+'" onclick="getSubFileList(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a></li>');
|
|
}else{
|
|
items.push('<li id="' + key + '">' + val['filename'] + '</li>');
|
|
}
|
|
});
|
|
$("#div_"+id).html(items.join(''));
|
|
}).complete(function(){
|
|
if($("#div_"+id)){
|
|
$('#span_'+id).html('-');
|
|
}
|
|
});
|
|
}
|
|
|
|
function googleSearch(keyword){
|
|
$.ajax({type:"POST",url:"/service/googlesearch",data:'q='+keyword,
|
|
success:function(html){
|
|
var items = [];
|
|
var obj = jQuery.parseJSON(html);
|
|
$.each(obj.responseData.results, function(key, val) {
|
|
var html = '<p><a href="' +val['unescapedUrl']+'">'+val['title']+'<a/></p><p><span>'
|
|
+val['url'].replace(/%(.*)/i,"") +'</span></p><p>'
|
|
+val['content']
|
|
+'</p>';
|
|
items.push('<li>' + html + '</li>');
|
|
});
|
|
items.push('<li class="more"><a href="'+obj.responseData.cursor.moreResultsUrl+'" target="_blank">查看更多搜索结果(约'+obj.responseData.cursor.estimatedResultCount+'条)</a></div>');
|
|
$('#searchlist').html(items.join(''));
|
|
searchFinish();
|
|
},
|
|
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');},
|
|
error:function(){$('#searchlist').html('');Alert('检索中发现错误,请稍后重试或直接访问');}
|
|
});
|
|
}
|
|
|
|
function scholarSearch(keyword){
|
|
$.ajax({type:"POST",url:"/service/scholarsearch",data:'q='+keyword,
|
|
success:function(html){
|
|
//$('#searchlist').html(html);return false;
|
|
var items = [];
|
|
var obj = jQuery.parseJSON(html);
|
|
if(obj.error != '')
|
|
{
|
|
items.push('<li>' + obj.error + '</li>');
|
|
}else{
|
|
$.each(obj.result, function(key, val) {
|
|
var html = val['title']
|
|
+'<p>'
|
|
+val['content']
|
|
+'</p>';
|
|
items.push('<li>' + html + '</li>');
|
|
});
|
|
}
|
|
items.push('<li class="more"><a href="'+obj.morelink+'" target="_blank">查看更多搜索结果</a></div>');
|
|
$('#searchlist').html(items.join(''));
|
|
searchFinish();
|
|
},
|
|
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');},
|
|
error:function(){$('#searchlist').html('');Alert('检索中发现错误,请稍后重试或直接访问');}
|
|
});
|
|
}
|
|
|
|
function bingSearch(keyword){
|
|
$.ajax({type:"POST",url:"/service/bingsearch",data:'q='+keyword,
|
|
success:function(html){
|
|
var items = [];
|
|
var obj = jQuery.parseJSON(html);
|
|
if($.isArray(obj.SearchResponse.Web))
|
|
{
|
|
if(obj.SearchResponse.Web.Total==0)
|
|
{
|
|
$('#searchlist').html("No results!");
|
|
return false;
|
|
}
|
|
$.each(obj.SearchResponse.Web.Results, function(key, val) {
|
|
var html = '<p><a href="' +val['Url']+'">'+val['Title']+'<a/></p><p><span>'
|
|
+val['DisplayUrl'].replace(/%(.*)/i,"") +'</span></p><p>'
|
|
+val['Description']
|
|
+'</p>';
|
|
items.push('<li>' + html + '</li>');
|
|
});
|
|
items.push('<li class="more"><a href="http://cn.bing.com/search?q='+encodeURIComponent(keyword)+
|
|
'&go=&qs=n&sk=&form=QBLH" target="_blank">查看更多搜索结果(约'+obj.SearchResponse.Web.Total+'条)</a></div>');
|
|
}else{
|
|
Alert('暂无搜索结果');$('#searchlist').html('');
|
|
}
|
|
$('#searchlist').html(items.join(''));
|
|
searchFinish();
|
|
},
|
|
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');},
|
|
error:function(){$('#searchlist').html('');Alert('检索中发现错误,请稍后重试或直接访问');}
|
|
});
|
|
}
|
|
|
|
function cnkiSearch(keyword){
|
|
$.ajax({type:"POST",url:"/service/cnkisearch",data:'q='+keyword,
|
|
success:function(html){
|
|
var items = [];
|
|
var obj = jQuery.parseJSON(html);
|
|
if(obj.error != '')
|
|
{
|
|
items.push('<li>' + obj.error + '</li>');
|
|
}else{
|
|
$.each(obj.result, function(key, val) {
|
|
var html = '<p><a href="' +val['url']+'" target="_blank">'+val['title']+'</a></p><p><span>'
|
|
+val['url'].replace(/%(.*)/i,"") +'</span></p><p>'
|
|
+val['content']
|
|
+'</p>';
|
|
|
|
items.push('<li>' + html + '</li>');
|
|
});
|
|
}
|
|
items.push('<li class="more"><a href="'+obj.morelink+'" target="_blank">查看更多搜索结果</a></div>');
|
|
$('#searchlist').html(items.join(''));
|
|
searchFinish()
|
|
},
|
|
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');},
|
|
error:function(){Alert('检索中发现错误,请稍后重试或直接访问');$('#searchlist').html('');}
|
|
});
|
|
}
|
|
|
|
function searchFinish()
|
|
{
|
|
$('html, body').animate({scrollTop:$('#gsearch_t').offset().top}, 'slow');
|
|
}
|
|
|
|
function dataVersion(uuid)
|
|
{
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url':'/data/getversion',
|
|
'data':'ac=list&uuid='+uuid,
|
|
'success':onDataVersionLoad,
|
|
'timeout': 30000,
|
|
'error': function(){Alert('处理中出现错误,请刷新页面后重试');return false;}
|
|
});
|
|
|
|
}
|
|
function onDataVersionLoad(data){
|
|
if (typeof(data)=='object')
|
|
{
|
|
if(typeof(data.error)!='undefined')
|
|
{Alert(data.error);return false;}
|
|
if(typeof(data.list)!='undefined')
|
|
{
|
|
var html = "";
|
|
for(v in data.list)
|
|
{
|
|
html+='<li><p>'+data.list[v].changelog+'</p><p>'+data.list[v].ts_created+' by '+data.list[v].username+'</p></li>';
|
|
}
|
|
$.colorbox({'innerWidth':'50%','innerHeight':'80%','html':'<div class="datalist"><ul>'+html+'</ul></div>'});
|
|
}
|
|
}
|
|
else{
|
|
Alert('出现错误,请稍后再试');return false;
|
|
}
|
|
}
|
|
|
|
function Alert(html){
|
|
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
|
} |