- new yconf parameter global

- see http://forum.yacy-websuche.de/posting.php?mode=quote&f=9&p=14207#pr14207

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5873 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
apfelmaennchen 16 years ago
parent 5ca306da9a
commit 64ce9da60f

@ -1,14 +1,15 @@
$(document).ready(function() { $(document).ready(function() {
$.ajaxSetup({ $.ajaxSetup({
timeout: 10000, timeout: 15000,
cache: true cache: true
}) })
// apply default properties // apply default properties
startRecord = 0; startRecord = 0;
maximumRecords = 10; maximumRecords = 10;
submit = false;
yconf = $.extend({ yconf = $.extend({
url : 'is a mandatory property - no default', url : 'is a mandatory property - no default',
global : false,
theme : 'start', theme : 'start',
title : 'YaCy P2P Web Search', title : 'YaCy P2P Web Search',
logo : yconf.url + '/yacy/ui/img/yacy-logo.png', logo : yconf.url + '/yacy/ui/img/yacy-logo.png',
@ -75,17 +76,20 @@ $(document).ready(function() {
} }
}); });
}); });
$('#ysearch').keyup(function() { $('#ysearch').keyup(function() {
startRecord = 0; startRecord = 0;
$('#ysearch').trigger('submit'); if(!submit) yacysearch(false);
else submit = false;
return false; return false;
}); });
$('#ysearch').submit(function() { $('#ysearch').submit(function() {
submit = true;
yacysearch(yconf.global);
return false;
});
});
function yacysearch(global) {
var url = yconf.url + '/yacysearch.json?callback=?' var url = yconf.url + '/yacysearch.json?callback=?'
$('#ypopup').empty(); $('#ypopup').empty();
$('#ypopup').append("<div class='yloading'><h3 class='linktitle'><em>Loading: "+yconf.url+"</em><br/><img src='"+yconf.url+"/yacy/ui/img/loading2.gif' align='absmiddle'/></h3></div>"); $('#ypopup').append("<div class='yloading'><h3 class='linktitle'><em>Loading: "+yconf.url+"</em><br/><img src='"+yconf.url+"/yacy/ui/img/loading2.gif' align='absmiddle'/></h3></div>");
@ -93,29 +97,31 @@ $(document).ready(function() {
$("#ypopup").dialog('open'); $("#ypopup").dialog('open');
} }
$("#yquery").focus(); $("#yquery").focus();
var param = []; var param = [];
$("#ysearch input").each(function(i){ $("#ysearch input").each(function(i){
var item = { name : $(this).attr('name'), value : $(this).attr('value') }; var item = { name : $(this).attr('name'), value : $(this).attr('value') };
if(global && (item.name == 'resource')) item.value = 'global';
param[i] = item; param[i] = item;
}); });
param[param.length] = { name : 'startRecord', value : startRecord }; param[param.length] = { name : 'startRecord', value : startRecord };
$.getJSON(url, param, $.getJSON(url, param,
function(json, status){ function(json, status){
if (json[0]) data = json[0]; if (json[0]) data = json[0];
else data = json; else data = json;
$('#ypopup').empty(); $('#ypopup').empty();
var total = data.channels[0].totalResults.replace(/[,.]/,""); var total = data.channels[0].totalResults.replace(/[,.]/,"");
if(global && (total == 0)) {
yacysearch(global);
return false;
}
var page = (data.channels[0].startIndex / data.channels[0].itemsPerPage) + 1; var page = (data.channels[0].startIndex / data.channels[0].itemsPerPage) + 1;
var start = startRecord + 1; var start = startRecord + 1;
var end = startRecord + maximumRecords; var end = startRecord + maximumRecords;
$("div .ybpane").remove(); $("div .ybpane").remove();
if(global) var result = 'global';
else var result = 'local';
var ylogo = "<div class='ybpane'><a href='"+yconf.link+"' target='_blank'><img src='"+yconf.logo+"' alt='"+yconf.logo+"' title='"+yconf.logo+"' /></a></div>"; var ylogo = "<div class='ybpane'><a href='"+yconf.link+"' target='_blank'><img src='"+yconf.logo+"' alt='"+yconf.logo+"' title='"+yconf.logo+"' /></a></div>";
var yresult = "<div class='ybpane'><em>Displaying result "+start+" to "+end+"<br/> of "+total+" total results.</em></div>"; var yresult = "<div class='ybpane'><em>Displaying result "+start+" to "+end+"<br/> of "+total+" "+result+" results.</em></div>";
$("div .ui-dialog-buttonpane").prepend(ylogo+yresult); $("div .ui-dialog-buttonpane").prepend(ylogo+yresult);
$.each ( $.each (
@ -138,6 +144,4 @@ $(document).ready(function() {
}); });
} }
); );
return false; }
});
});

@ -9,6 +9,7 @@
$(document).ready(function() { $(document).ready(function() {
yconf = { yconf = {
url : 'http://localhost:8080', url : 'http://localhost:8080',
global: true,
theme : 'start', theme : 'start',
title : 'YaCy Portal Search' title : 'YaCy Portal Search'
}; };
@ -36,6 +37,7 @@
$(document).ready(function() { $(document).ready(function() {
yconf = { yconf = {
url : 'http://localhost:8080', url : 'http://localhost:8080',
global : true
theme : 'start', theme : 'start',
title : 'YaCy Portal Search' title : 'YaCy Portal Search'
}; };
@ -59,6 +61,7 @@
<h4>Configuration options and defaults for 'yconf':</h4> <h4>Configuration options and defaults for 'yconf':</h4>
<pre> <pre>
url : 'is a mandatory property - no default', url : 'is a mandatory property - no default',
global : false,
theme : 'start', theme : 'start',
title : 'YaCy P2P Web Search', title : 'YaCy P2P Web Search',
logo : '/yacy/ui/img/yacy-logo.png', logo : '/yacy/ui/img/yacy-logo.png',

Loading…
Cancel
Save