function literature_get(page,uuid){
$.ajax({
type:"GET",
url:"/service/literature/uuid/"+uuid,
data:'page='+page,
success:function(html){$('#literature-list').html('
'+html+'
');},
beforeSend:function(){$('#literature-list').html('加载中');}
});
}
function recommend_get(page,uuid){
$.ajax({
type:"GET",
url:"/service/recommend/uuid/"+uuid,
data:'page='+page,
success:function(html){$('#recommend').html('');},
beforeSend:function(){$('#recommend').html('加载中');}
});
}
function related_get(page,uuid){
$.ajax({
type:"GET",
url:"/service/related/uuid/"+uuid,
data:'page='+page,
success:function(html){$('#related').html(''+html+'
');},
beforeSend:function(){$('#related').html('加载中');}
});
}
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('正在提交...');
}
});
}
function getSubFileList(uuid,id,depth){
if($("#div_"+id).length>0)
{
$('#span_'+id).html('+');
$("#div_"+id).remove();
return false;
}
$('', {
'style':'overflow:auto;',
'id': 'div_'+id,
"html": '加载中'
}).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('+ ' + val['filename'] + '');
}else{
items.push('' + val['filename'] + '');
}
});
$("#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 = ''+val['title']+'
'
+val['url'].replace(/%(.*)/i,"") +'
'
+val['content']
+'
';
items.push('' + html + '');
});
items.push('查看更多搜索结果(约'+obj.responseData.cursor.estimatedResultCount+'条)');
$('#searchlist').html(items.join(''));
searchFinish();
},
beforeSend:function(){$('#searchlist').html('结果加载中');},
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('' + obj.error + '');
}else{
$.each(obj.result, function(key, val) {
var html = val['title']
+''
+val['content']
+'
';
items.push('' + html + '');
});
}
items.push('查看更多搜索结果');
$('#literature-list').html(items.join(''));
searchFinish();
},
beforeSend:function(){$('#literature-list').html('结果加载中');},
error:function(){$('#literature-list').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('' + obj.error + '');
}else{
$.each(obj.result, function(key, val) {
var html = ''+val['title']+'
'
+val['url'].replace(/%(.*)/i,"") +'
'
+val['content']
+'
';
items.push('' + html + '');
});
}
items.push('查看更多搜索结果');
$('#literature-list').html(items.join(''));
searchFinish()
},
beforeSend:function(){$('#literature-list').html('结果加载中');},
error:function(){Alert('检索中发现错误,请稍后重试或直接访问');$('#literature-list').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+=''+data.list[v].changelog+'
'+data.list[v].ts_created+' by '+data.list[v].username+'
';
}
$.colorbox({'innerWidth':'50%','innerHeight':'80%','html':''});
}
}
else{
Alert('出现错误,请稍后再试');return false;
}
}
function Alert(html){
$.colorbox({'innerWidth':'50%','html':''+html+'
'});
}
function getFileList_h(uuid){
html =''
+ '
'
+ '
'
+ '
加载中...
'
+ '
'
+ '
'
+ '
'
+ '
'
+'
';
$.colorbox({width:"80%",height:"80%",html:html});
$.getJSON("/service/filelist/uuid/"+uuid, function(data) {
var items = [];
if(data.length>0)
{
$.each(data, function(key, val) {
if(val['filename'].match(/\/$/))
{
items.push('+ ' + val['filename'] + '');
}else{
items.push('' + val['filename'] + '');
}
});
}else{
items.push('暂无数据');
}
$('#file-list').html(items.join(''));
})
.complete(function() {
$('#window-loading').hide();
});
}
function ajaxpage_get(page,uuid){
var url = "/data/comment/uuid/"+uuid;
data='page='+page;
$.ajax({
type:"GET",
url:url,
data:data,
success:function(html){$('#allcomments').html(html);},
beforeSend:function(){$('#allcomments').html('评论加载中');}
});
};
//map
//加载地图
function initialize() {
var myLatlng = new google.maps.LatLng(bound.lat,bound.lng);
zoomlevel = bound.zoom;
var myOptions = {
zoom: zoomlevel,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
}
map = new google.maps.Map(document.getElementById(mapElementID), myOptions);
setRectangle(bound.east,bound.west,bound.south,bound.north);
}
function setRectangle(east,west,south,north){
bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(south,west),
new google.maps.LatLng(north,east)
);
rectangle = new google.maps.Rectangle({
bounds: bounds,
editable: false
});
rectangle.setMap(map);
var bounds = new google.maps.LatLngBounds();
bounds.extend(new google.maps.LatLng(south, west));
bounds.extend(new google.maps.LatLng(north,east));
map.fitBounds(bounds);
}