fix metadata view page files list bug

This commit is contained in:
Li Jianxuan 2013-04-13 08:58:58 +00:00
parent 905622102d
commit 77ec3f7306
4 changed files with 1818 additions and 1751 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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