修改数据页面JS代码,封装独立函数
This commit is contained in:
parent
e00969668a
commit
6ac2fbf4f7
|
@ -127,10 +127,10 @@ if ($md->title_en) echo '<br />'.$this->escape($md->title_en);?>
|
||||||
</div>
|
</div>
|
||||||
<div id="literature" class="tab-pane">
|
<div id="literature" class="tab-pane">
|
||||||
<div class="">
|
<div class="">
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills lit-nav">
|
||||||
<li><a href="javascript:;" class="literatures">西部计划知识库</a></li>
|
<li><a href="javascript:;" class="literatures lit-nav-btn">西部计划知识库</a></li>
|
||||||
<li><a href="javascript:;" class="scholar">Google学术搜索</a></li>
|
<li><a href="javascript:;" class="scholar lit-nav-btn">Google学术搜索</a></li>
|
||||||
<li><a href="javascript:;" class="cnkiSearch">CNKI学术搜索</a></li>
|
<li><a href="javascript:;" class="cnkiSearch lit-nav-btn">CNKI学术搜索</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="literature-list">
|
<div id="literature-list">
|
||||||
|
@ -392,131 +392,71 @@ endforeach;
|
||||||
</div>
|
</div>
|
||||||
<script src="/js/metadata-view.js"></script>
|
<script src="/js/metadata-view.js"></script>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
ajaxpage(0);
|
|
||||||
$('#literature_t').click(function(){literature(1);});
|
|
||||||
//ajax literature
|
|
||||||
function literature(page){$.ajax({type:"GET",url:"/service/literature/uuid/<?= $md->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" />加载中');}});}
|
|
||||||
|
|
||||||
$('#related_t').click(function(){related(1);});
|
|
||||||
//ajax related
|
|
||||||
function related(page){$.ajax({type:"GET",url:"/service/related/uuid/<?= $md->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" />加载中');}});};related(1);
|
|
||||||
|
|
||||||
$('#recommend_t').click(function(){recommend(0);});
|
|
||||||
//ajax recommend
|
|
||||||
function recommend(page){$.ajax({type:"GET",url:"/service/recommend/uuid/<?= $md->uuid; ?>",data:'page='+page,success:function(html){$('#recommend').html('<ul>'+html+'</ul>');},
|
|
||||||
beforeSend:function(){$('#recommend').html('<img src="/images/loading.gif" />加载中');}});}
|
|
||||||
|
|
||||||
function getFileList(){
|
|
||||||
html ='<div id="window-outter">'
|
|
||||||
+ '<div id="window-inner">'
|
|
||||||
+ '<div id="window-content-container">'
|
|
||||||
+ '<div id="window-loading">加载中...</div>'
|
|
||||||
+ '<ol id="file-list">'
|
|
||||||
+ '</ol>'
|
|
||||||
+ '</div>'
|
|
||||||
+ '</div>'
|
|
||||||
+'</div>';
|
|
||||||
$.colorbox({width:"80%",height:"80%",html:html});
|
|
||||||
$.getJSON("/service/filelist/uuid/<?php echo $md->uuid;?>", function(data) {
|
|
||||||
var items = [];
|
|
||||||
if(data.length>0)
|
|
||||||
{
|
|
||||||
$.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="li_' + val['id'] + '">' + val['filename'] + '</li>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
items.push('<li>暂无数据</li>');
|
|
||||||
}
|
|
||||||
$('#file-list').html(items.join(''));
|
|
||||||
})
|
|
||||||
.complete(function() {
|
|
||||||
$('#window-loading').hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function ajaxpage(page){
|
|
||||||
var url = "/data/comment/uuid/<?= $md->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" />评论加载中');}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$('#gsearch_t').click(function(){
|
|
||||||
if($('#searchlist').children('li').length<1)
|
|
||||||
{
|
|
||||||
googleSearch('<?php echo $ev;?>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.literatures').click(function(){literature(1);});
|
|
||||||
$('.googlesearch').click(function(){googleSearch('<?php echo $ev;?>');});
|
|
||||||
$('.bingsearch').click(function(){bingSearch('<?php echo $ev;?>');});
|
|
||||||
$('.cnkiSearch').click(function(){cnkiSearch('<?php echo $ev;?>');});
|
|
||||||
$('.scholar').click(function(){scholarSearch('<?php echo $ev;?>');});
|
|
||||||
|
|
||||||
var map = null;
|
|
||||||
var mapElementID = null;
|
|
||||||
var bounds = null;
|
|
||||||
var rectangle = null;
|
|
||||||
var zoomlevel = 1;
|
|
||||||
|
|
||||||
function initialize() {
|
|
||||||
//加载地图
|
|
||||||
var myLatlng = new google.maps.LatLng(<?= ($md->south+$md->north)/2; ?>,<?= ($md->east+$md->west)/2; ?>);
|
|
||||||
|
|
||||||
mapElementID = "watermap";
|
|
||||||
|
|
||||||
<?php if ($md->north==$md->south) : ?>
|
|
||||||
zoomlevel=10;
|
|
||||||
<?php endif; ?>
|
|
||||||
if (zoomlevel>16) zoomlevel=16;
|
|
||||||
|
|
||||||
var myOptions = {
|
|
||||||
zoom: zoomlevel,
|
|
||||||
center: myLatlng,
|
|
||||||
mapTypeId: google.maps.MapTypeId.HYBRID
|
|
||||||
}
|
|
||||||
map = new google.maps.Map(document.getElementById(mapElementID), myOptions);
|
|
||||||
|
|
||||||
setRectangle(<?= $md->east; ?>,<?= $md->west; ?>,<?= $md->south; ?>,<?= $md->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(<?= $md->south; ?>, <?= $md->west; ?>));
|
|
||||||
bounds.extend(new google.maps.LatLng(<?= $md->north; ?>,<?= $md->east; ?>));
|
|
||||||
map.fitBounds(bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
google.maps.event.addDomListener(window, 'load', initialize);
|
google.maps.event.addDomListener(window, 'load', initialize);
|
||||||
$(".colorbox").colorbox({photo:"true"});
|
$(".colorbox").colorbox({photo:"true"});
|
||||||
|
$('.googlesearch').click(function(){googleSearch('<?php echo $ev;?>');});
|
||||||
|
$('.bingsearch').click(function(){bingSearch('<?php echo $ev;?>');});
|
||||||
|
$('.cnkiSearch').click(function(){cnkiSearch('<?php echo $ev;?>');});
|
||||||
|
$('.scholar').click(function(){scholarSearch('<?php echo $ev;?>');});
|
||||||
|
$('#related_t').click(function(){related(1);});
|
||||||
|
$('#recommend_t').click(function(){recommend(0);});
|
||||||
|
$('#literature_t').click(function(){literature(1);$('.literatures').parent('li').addClass('active')});
|
||||||
|
$('.literatures').click(function(){literature(1);});
|
||||||
|
ajaxpage(0);
|
||||||
|
related(1);
|
||||||
|
$('.lit-nav-btn').each(function(index, element) {
|
||||||
|
$(this).click(function(){
|
||||||
|
$('.lit-nav').children('li').each(function(index, element) {
|
||||||
|
$(this).removeClass('active');
|
||||||
|
});
|
||||||
|
$(this).parent('li').addClass('active');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#gsearch_t').click(function(){
|
||||||
|
if($('#searchlist').children('li').length<1)
|
||||||
|
{
|
||||||
|
googleSearch('<?php echo $ev;?>');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
//ajax literature
|
||||||
|
function literature(page){
|
||||||
|
literature_get(page,'<?= $md->uuid; ?>');
|
||||||
|
}
|
||||||
|
|
||||||
|
//ajax related
|
||||||
|
function related(page){
|
||||||
|
related_get(page,'<?= $md->uuid; ?>');
|
||||||
|
}
|
||||||
|
|
||||||
|
//ajax recommend
|
||||||
|
function recommend(page){
|
||||||
|
recommend_get(page,'<?= $md->uuid; ?>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileList(){
|
||||||
|
getFileList_h('<?php echo $md->uuid;?>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function ajaxpage(page){
|
||||||
|
ajaxpage_get(page,'<?= $md->uuid; ?>');
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = null;
|
||||||
|
var mapElementID = "watermap";
|
||||||
|
var bounds = null;
|
||||||
|
var rectangle = null;
|
||||||
|
var zoomlevel = 1;
|
||||||
|
var bound = {
|
||||||
|
lat:<?= ($md->south+$md->north)/2; ?>,
|
||||||
|
lng:<?= ($md->east+$md->west)/2; ?>,
|
||||||
|
zoom:<?php if ($md->north==$md->south) { ?> 10 <?php }else {?> 16 <?php }?>,
|
||||||
|
east:<?= $md->east; ?>,
|
||||||
|
west:<?= $md->west; ?>,
|
||||||
|
south:<?= $md->south; ?>,
|
||||||
|
north:<?= $md->north; ?>
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p>Cannot find the metadata.</p>
|
<p>Cannot find the metadata.</p>
|
||||||
|
|
|
@ -1,3 +1,33 @@
|
||||||
|
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" />加载中');}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function postcomment(){
|
function postcomment(){
|
||||||
var url="/data/postcomment";
|
var url="/data/postcomment";
|
||||||
var date = $('#postcommentform').serialize();
|
var date = $('#postcommentform').serialize();
|
||||||
|
@ -163,4 +193,86 @@ function onDataVersionLoad(data){
|
||||||
|
|
||||||
function Alert(html){
|
function Alert(html){
|
||||||
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFileList_h(uuid){
|
||||||
|
html ='<div id="window-outter">'
|
||||||
|
+ '<div id="window-inner">'
|
||||||
|
+ '<div id="window-content-container">'
|
||||||
|
+ '<div id="window-loading">加载中...</div>'
|
||||||
|
+ '<ol id="file-list">'
|
||||||
|
+ '</ol>'
|
||||||
|
+ '</div>'
|
||||||
|
+ '</div>'
|
||||||
|
+'</div>';
|
||||||
|
$.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('<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="li_' + val['id'] + '">' + val['filename'] + '</li>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
items.push('<li>暂无数据</li>');
|
||||||
|
}
|
||||||
|
$('#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('<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){
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
Loading…
Reference in New Issue