westdc-zf1/application/default/views/scripts/author/apply.phtml

107 lines
3.4 KiB
PHTML

<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据作者</a>');
$this->breadcrumb('申请成为元数据作者');
$this->breadcrumb()->setSeparator(' > ');
?>
<!-- 左侧导航 -->
<div id='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<p>请输入元数据标题关键字进行搜索</p>
<form id="datasearch" class="search_form">
<input type="text" id="keyword" name="keyword" />
<button type="button" class="btn" id="search_btn" onclick="doSearch()">搜索</button>
</form>
<div id="datalist">
</div>
</div>
<!-- //页面内容 -->
<script>
$('#wapper').width($('body').width()-300);
function doSearch(){
$.ajax({
'type':"POST",
'url':'/author/apply',
'data':'ac=search&q='+$('#keyword').val(),
'success':function(data){
if (isObject(data))
{
if(typeof(data.error)!='undefined')
{
alert(data.error);
}else{
var result = new Array();
for(i=0;i<data.length;i++)
{
if(data[i].status==1) var ct='<img src="/images/list_links.gif" />您是此元数据的作者';
else if (data[i].status==0) var ct='<img src="/images/list_extensions.gif" />您已经申请成为该元数据作者,请前往 <a href="/author/accept">我的数据</a> 查看<span id="data_'+data[i].uuid+'"></span>';
else var ct='<a href="javascript:;" onclick="apply(\'' +data[i].uuid+ '\')"><img src="/images/list_keys.gif" />申请成为此数据的作者</a><span id="data_'+data[i].uuid+'"></span>';
result.push('<li><a href="/data/'+data[i].uuid+'" target="_blank" class="title">'+data[i].title+'</a><p>'+data[i].description+'</p><p>'+ct+'</p></li>');
}
$('#datalist').html('<ul id="datas">'+result.join('')+'</ul>');
}
}else{
alert('无搜索结果');
}
$('#search_btn').html('搜索');
},
'beforeSend':function(){
$('#search_btn').html('<img src="/images/ajax-load-small.gif" />Searching...');
},
'timeout': 20000,
'error': function(){
alert('处理中出现问题,请重试');
$('#data_'+uuid).html('');
}
});
}
function apply(uuid){
$.ajax({
'type':"POST",
'url':'/author/apply',
'data':'ac=apply&uuid='+uuid,
'success':function(data){
if (isObject(data))
{
if(typeof(data.error)!='undefined')
{alert(data.error);}
else{
alert(data.error);
}
}
else{ alert('出现错误,请稍候');}
$('#data_'+uuid).html('');
},
'beforeSend':function(){
$('#data_'+uuid).html('<img src="/images/ajax-load-small.gif" />正在处理...');
},
'timeout': 30000,
'error': function(){
alert('处理中出现问题,请重试');
$('#data_'+uuid).html('');
}
});
}
function isObject(obj){if(typeof(obj)=='object'){return true;}else if(typeof(obj)!='object'){return false;}else{return false;}}
$('#datasearch').bind('submit',function(){
return false;
});
$("#keyword").die().live("keydown",function(event){
if(event.keyCode==13){
$('#search_btn').click();
}
});
</script>