在heihe项目元数据查看中增加了google ajax search实现的相关搜索功能

This commit is contained in:
Li Jianxuan 2011-11-14 02:31:28 +00:00
parent 4b5afe8ed9
commit b1b2419d72
1 changed files with 37 additions and 1 deletions

View File

@ -277,7 +277,17 @@ echo '【'.$r->author.'. '.$r->publisher.' '.$r->ts_issued.'】</li>';
<?php endif; ?> <?php endif; ?>
</div> </div>
<div id="gsearch"> <div id="gsearch">
<p>用GOOGLE搜索本数据的关键词有以下结果</p> <ul id="searchctrl">
<?php
foreach($this->keys as $cg){
echo '<li><a href="javascript:;" onclick="googlesearch(\''.$cg->keyword.'\');">'.$cg->keyword.'</a></li>'."\r\n";
}
?>
</ul>
<ul id="searchlist">
</ul>
</div> </div>
<div id="recommend"> <div id="recommend">
<p>申请了本条数据的用户,通常他们还申请了:</p> <p>申请了本条数据的用户,通常他们还申请了:</p>
@ -300,6 +310,7 @@ echo '【'.$r->author.'. '.$r->publisher.' '.$r->ts_issued.'】</li>';
</div> </div>
</div> </div>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(document).ready(function(){$(".colorbox").colorbox({photo:"true"});}); $(document).ready(function(){$(".colorbox").colorbox({photo:"true"});});
$(window).bind("load", function() { var timeout = setTimeout(function() { initLoader(); }, 100);}); $(window).bind("load", function() { var timeout = setTimeout(function() { initLoader(); }, 100);});
//$(window).bind("load", function() { var timeout = setTimeout(function() { gmaploaded(); }, 1000);}); //$(window).bind("load", function() { var timeout = setTimeout(function() { gmaploaded(); }, 1000);});
@ -395,6 +406,31 @@ function getSubFileList(uuid,id,depth){
} }
}); });
} }
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>');
});
$('#searchlist').html(items.join(''));
},
beforeSend:function(){
$('#searchlist').html('<img src="/images/11887177066.gif" />结果加载中');
}
});
}
function gmaploaded() function gmaploaded()
{ {
//google map //google map