You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yacy_search_server/htroot/yacy/ui/yacyuisearch.html

171 lines
6.3 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link media="screen" type="text/css" href="css/jquery.flexigrid.css" rel="stylesheet" />
<link media="screen" type="text/css" href="css/base.css" rel="stylesheet" />
<script src="js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="js/jquery.query.js" type="text/javascript""></script>
<script src="js/jquery.dimensions.min.js" type="text/javascript"></script>
<script src="js/jquery-faviconize-1.0.js" type="text/javascript"></script>
<script src="js/jquery-flexigrid.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
var height = document.documentElement.clientHeight - 240;
var query = $.query.get('search');
$.query.REMOVE('search');
$(".yresult").flexigrid({
url: '/yacysearch.json',
dataType: 'json',
method: 'GET',
query: query,
colModel: [
{display: 'Hash', name : 'hash', width : 50, sortable : false, align: 'center', hide: true},
{display: '', name : 'public', width : 25, sortable : true, align: 'center'},
{display: 'Title', name : 'title', width : 550, sortable : true, align: 'left'},
{display: 'Date', name : 'date', width : 200, sortable : true, align: 'left'}
],
buttons: [
{name: 'Crawl', bclass: 'crawl', onpress: yaction},
{name: 'Open', bclass: 'pictures', onpress: yaction},
{separator: true},
{name: 'Bookmark', bclass: 'bookmark', onpress: yaction},
{name: 'Blacklist', bclass: 'blacklist', onpress: yaction},
{separator: true},
{name: 'Help', bclass: 'help', onpress:yaction},
],
useRp: true,
rp: 10,
usepager: true,
striped: true,
nowrap: false,
height: height,
autoload: true,
onSuccess: function() {
$("a.favicon").faviconize({
position: "before",
defaultImage: "img-2/article.png",
className: "favicon"
});
},
preProcess: function(data) {
var total = data.channels[0].totalResults.replace(/[,.]/,"");
var page = (data.channels[0].startIndex / data.channels[0].itemsPerPage) + 1;
var rows = {};
$.each (
data.channels[0].items,
function(i,item) {
if (item) {
var html = "<h3 class='linktitle'>"+item.title+"</h3><p class='desc'>"+item.description+"</p><p class='url'><a href='"+item.link+"'>"+item.link+"</a>"
var fav = "<a class='favicon' href='"+item.link+"'></a>";
rows[i] = {id: item.guid, cell: [item.guid, fav, html, item.pubDate]};
}
}
);
var pdata = {
page: page,
total: total,
rows: rows
};
return pdata;
},
onSubmit: function() {
var p = this;
var g = $(".yresult");
$('.pPageStat',this.pDiv).html(p.procmsg);
$('.pReload',this.pDiv).addClass('loading');
if (g.bDiv) $(g.block).css({top:g.bDiv.offsetTop});
if (p.hideOnSubmit) $(this.gDiv).prepend(g.block); //$(t).hide();
if ($.browser.opera) $(t).css('visibility','hidden');
if (!p.newp) p.newp = 1;
if (p.page>p.pages) p.page = p.pages;
var offset = p.newp * p.rp -p.rp;
var prefermaskfilter = $.query.get('prefermaskfilter');
if(!prefermaskfilter) prefermaskfilter = '';
var constraint = $.query.get('constraint');
if(!constraint) constraint = '';
var language = $.query.get('language');
if (!language) language = '';
var verify = $.query.get('verify');
if (!verify) verify = 'true';
var urlmaskfilter = $.query.get('urlmaskfilter');
if (!urlmaskfilter) urlmaskfilter = '.*';
var param = [
{ name : 'startRecord', value : offset }
,{ name : 'maximumRecords', value : p.rp }
,{ name : 'search', value : p.query}
,{ name : 'urlmaskfilter', value : urlmaskfilter}
,{ name : 'prefermaskfilter', value: prefermaskfilter}
,{ name : 'verify', value : verify}
,{ name : 'contentdom', value : 'text'}
,{ name : 'constraint', value : constraint}
,{ name : 'language', value : language}
];
if (p.params) {
for (var pi = 0; pi < p.params.length; pi++) param[param.length] = p.params[pi];
}
$.ajax({
type: p.method,
url: p.url,
data: param,
dataType: p.dataType,
success: function(data){
/* yacy limits itemsPerPage for unauthenticated users */
p.rp = parseInt(data.channels[0].itemsPerPage);
g.flexAddData(data);
},
error: function(data) {
try { if (p.onError) p.onError(data); } catch (e) {}
}
});
}
});
});
function yaction(com, grid) {
if (com == 'Bookmark') {
confirm('Add ' + $('.trSelected',grid).length + ' search results to bookmark(s)?')
$('.trSelected',grid).each(function(){
var url = $(this).find('.url').text();
var title = $(this).find('.linktitle').text();
var desc = $(this).find('.desc').text();
var tags = $.query.get('query');
var path = "/searchResults";
var pub = "private";
var query = "&url="+url+"&title="+title+"&description="+desc+"&tags="+tags+"&path="+path+"&public="+pub+"&add=create";
$.ajax({
type: "POST",
url: "/xml/bookmarks/posts/add_p.xml?login="+query,
dataType: "xml",
success: function(xml) {
alert("Debug: posted bookmark for: "+url);
}
});
});
} else if (com =='Open') {
$('.trSelected',grid).each(function(){
var url = $(this).find('.url').text();
window.open(url);
});
} else {
alert("Test!");
}
}
//]]>
</script>
<title>YaCy-UI Search</title>
</head>
<body>
<table class="yresult">
<tbody></tbody>
</table>
</body>
</html>