2013-06-18 09:04:45 +00:00
|
|
|
var method = {};
|
|
|
|
|
2013-07-19 10:18:07 +00:00
|
|
|
//收藏数据
|
|
|
|
method.like = function(uuid,btn){
|
|
|
|
text = $(btn).text();
|
|
|
|
current_event = $(btn).attr('onclick');
|
|
|
|
$.ajax({
|
|
|
|
type:"GET",
|
|
|
|
url:"/data/like/",
|
|
|
|
data:'uuid=' + uuid,
|
|
|
|
success:function(data){
|
|
|
|
if (typeof(data)=='object')
|
|
|
|
{
|
|
|
|
if(typeof(data.error) !== 'undefined')
|
|
|
|
{
|
|
|
|
Alert(data.error);return false;
|
|
|
|
}else{
|
|
|
|
Alert("收藏成功!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
Alert('出现错误,请稍后再试');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeSend:function(){
|
|
|
|
$(btn).removeAttr('onclick');
|
|
|
|
$(btn).html('<img src="/images/ajax-load-small.gif" />');
|
|
|
|
},
|
|
|
|
timeout: 15000,
|
|
|
|
error: function(){
|
|
|
|
Alert('处理中出现错误,请刷新页面后重试');
|
|
|
|
},
|
|
|
|
complete:function(){
|
|
|
|
$(btn).attr('onclick',current_event);
|
|
|
|
$(btn).html(text);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//文件列表
|
2013-06-18 09:04:45 +00:00
|
|
|
method.filelist = {
|
|
|
|
get : function(uuid){
|
|
|
|
html ='<div id="window-outter">'
|
|
|
|
+ '<div id="window-inner">'
|
|
|
|
+ '<div id="window-content-container">'
|
|
|
|
+ '<div id="window-loading"><div class="progress progress-striped active"><div class="bar" style="width:100%;"></div></div></div>'
|
|
|
|
+ '<ol id="file-list">'
|
|
|
|
+ '</ol>'
|
|
|
|
+ '</div>'
|
|
|
|
+ '</div>'
|
|
|
|
+'</div>';
|
|
|
|
$.colorbox({width:"80%",height:"80%",html:html});
|
|
|
|
$.getJSON("/service/filelist/uuid/"+uuid, function(data) {
|
|
|
|
items = method.filelist.makelist(data);
|
|
|
|
$('#file-list').html(items.join(''));
|
|
|
|
})
|
|
|
|
.complete(function() {
|
|
|
|
$('#window-loading').hide();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getsub: function(uuid,id,depth){
|
|
|
|
if($("#div_"+id).length>0)
|
|
|
|
{
|
|
|
|
$('#icon_'+id).attr('class','icon-folder-close-alt');
|
|
|
|
$("#div_"+id).remove();
|
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
$('#icon_'+id).attr('class','icon-folder-open-alt');
|
|
|
|
}
|
|
|
|
$('<div/>', {
|
|
|
|
'style':'overflow:auto;',
|
|
|
|
'id': 'div_'+id,
|
2013-06-18 12:09:16 +00:00
|
|
|
"html": '<li><i class="icon-spinner icon-spin icon-large"></i>加载中</li>'
|
2013-06-18 09:04:45 +00:00
|
|
|
}).appendTo('#li_'+id);
|
|
|
|
url="/service/subfilelist/uuid/"+uuid+"/subpath/"+id+"/depth/"+depth;
|
|
|
|
$.getJSON(url, function(data) {
|
|
|
|
items = method.filelist.makelist(data);
|
2013-06-18 12:09:16 +00:00
|
|
|
$("#div_"+id).html('<ol>'+items.join('')+'</ol>');
|
2013-06-18 09:04:45 +00:00
|
|
|
}).complete(function(){
|
|
|
|
if($("#div_"+id)){
|
|
|
|
$('#span_'+id).html('-');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},//sublist
|
|
|
|
makelist : function(data)
|
|
|
|
{
|
|
|
|
items = [];
|
|
|
|
$.each(data, function(key, val) {
|
|
|
|
if(val['filename'].match(/\/$/))
|
|
|
|
{
|
|
|
|
html = '<li id="li_' + val['id'] + '">'
|
|
|
|
+'<i class="icon-folder-close-alt" id="icon_'+val['id']+'"></i>'
|
|
|
|
+'<a href="javascript:;" id="taget_'+val['id']+'" onclick="method.filelist.getsub(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a>'
|
|
|
|
+'</li>'
|
|
|
|
items.push(html);
|
|
|
|
}else{
|
|
|
|
html = '<li id="li_' + val['id'] + '">'
|
|
|
|
+'<i class="icon-file" id="icon_'+val['id']+'"></i> '
|
|
|
|
+ val['filename']
|
|
|
|
+'<span class="pull-right" style="margin-left:15px;">[时间:'+val['ts_created']+']</span>'
|
|
|
|
+'<span class="pull-right">[大小:'+val['filesize']+']</span>'
|
|
|
|
'</li>';
|
|
|
|
items.push(html);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return items;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-15 07:16:49 +00:00
|
|
|
function literature_get(page,uuid){
|
|
|
|
$.ajax({
|
|
|
|
type:"GET",
|
|
|
|
url:"/service/literature/uuid/"+uuid,
|
|
|
|
data:'page='+page,
|
|
|
|
success:function(html){$('#literature-list').html('<ol start="'+ ((page-1)*10+1) +'">'+html+'</ol>');},
|
|
|
|
beforeSend:function(){$('#literature-list').html('<img src="/images/loading.gif" />加载中');}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function recommend_get(page,uuid){
|
|
|
|
$.ajax({
|
|
|
|
type:"GET",
|
|
|
|
url:"/service/recommend/uuid/"+uuid,
|
|
|
|
data:'page='+page,
|
|
|
|
success:function(html){$('#recommend').html('<ul>'+html+'</ul>');},
|
|
|
|
beforeSend:function(){$('#recommend').html('<img src="/images/loading.gif" />加载中');}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function related_get(page,uuid){
|
|
|
|
$.ajax({
|
|
|
|
type:"GET",
|
|
|
|
url:"/service/related/uuid/"+uuid,
|
|
|
|
data:'page='+page,
|
|
|
|
success:function(html){$('#related').html('<ol start="'+ ((page-1)*10+1) +'">'+html+'</ol>');},
|
|
|
|
beforeSend:function(){$('#related').html('<img src="/images/loading.gif" />加载中');}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-04-15 02:34:12 +00:00
|
|
|
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 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>');
|
|
|
|
$('#literature-list').html(items.join(''));
|
|
|
|
searchFinish();
|
|
|
|
},
|
|
|
|
beforeSend:function(){$('#literature-list').html('<img src="/images/loading.gif" />结果加载中');},
|
|
|
|
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('<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>');
|
|
|
|
$('#literature-list').html(items.join(''));
|
|
|
|
searchFinish()
|
|
|
|
},
|
|
|
|
beforeSend:function(){$('#literature-list').html('<img src="/images/loading.gif" />结果加载中');},
|
|
|
|
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+='<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>'});
|
2013-04-15 07:16:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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('<img src="/images/loading.gif" />评论加载中');}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
//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){
|
|
|
|
|
2013-05-27 09:03:11 +00:00
|
|
|
if(east.toFixed(1) != west.toFixed(1) && south.toFixed(1)!= north.toFixed(1) ){
|
|
|
|
|
|
|
|
bounds = new google.maps.LatLngBounds(
|
|
|
|
new google.maps.LatLng(south,west),
|
|
|
|
new google.maps.LatLng(north,east)
|
|
|
|
);
|
2013-04-15 07:16:49 +00:00
|
|
|
|
2013-05-27 09:03:11 +00:00
|
|
|
rectangle = new google.maps.Rectangle({
|
|
|
|
bounds: bounds,
|
|
|
|
editable: false
|
|
|
|
});
|
|
|
|
|
2013-07-19 10:18:07 +00:00
|
|
|
rectangle.setMap(map);
|
2013-06-18 12:09:16 +00:00
|
|
|
|
2013-05-28 07:08:32 +00:00
|
|
|
|
2013-05-27 09:03:11 +00:00
|
|
|
}else{
|
|
|
|
|
|
|
|
var position = new google.maps.LatLng(south,east);
|
|
|
|
|
|
|
|
var marker = new google.maps.Marker({
|
|
|
|
position: position,
|
|
|
|
map: map,
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2013-05-28 07:08:32 +00:00
|
|
|
|
|
|
|
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);
|
2013-04-10 09:44:56 +00:00
|
|
|
}
|