From 64ce9da60f33d790610a9edff5592b5e0284b97a Mon Sep 17 00:00:00 2001 From: apfelmaennchen Date: Sat, 25 Apr 2009 13:08:07 +0000 Subject: [PATCH] - 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 --- htroot/yacy/ui/js/yacyui-portalsearch.js | 128 ++++++++++++----------- htroot/yacy/ui/yacyui-portaltest.html | 11 +- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/htroot/yacy/ui/js/yacyui-portalsearch.js b/htroot/yacy/ui/js/yacyui-portalsearch.js index 65bf363c5..9ce9196b0 100644 --- a/htroot/yacy/ui/js/yacyui-portalsearch.js +++ b/htroot/yacy/ui/js/yacyui-portalsearch.js @@ -1,14 +1,15 @@ $(document).ready(function() { - $.ajaxSetup({ - timeout: 10000, + timeout: 15000, cache: true }) // apply default properties startRecord = 0; maximumRecords = 10; + submit = false; yconf = $.extend({ url : 'is a mandatory property - no default', + global : false, theme : 'start', title : 'YaCy P2P Web Search', logo : yconf.url + '/yacy/ui/img/yacy-logo.png', @@ -75,69 +76,72 @@ $(document).ready(function() { } }); }); - $('#ysearch').keyup(function() { startRecord = 0; - $('#ysearch').trigger('submit'); + if(!submit) yacysearch(false); + else submit = false; return false; }); - - $('#ysearch').submit(function() { - - var url = yconf.url + '/yacysearch.json?callback=?' - - $('#ypopup').empty(); - $('#ypopup').append("

Loading: "+yconf.url+"

"); - - if (!$("#ypopup").dialog('isOpen')) { - $("#ypopup").dialog('open'); - } - $("#yquery").focus(); - - var param = []; - $("#ysearch input").each(function(i){ - var item = { name : $(this).attr('name'), value : $(this).attr('value') }; - param[i] = item; - }); - param[param.length] = { name : 'startRecord', value : startRecord }; - - $.getJSON(url, param, - function(json, status){ - if (json[0]) data = json[0]; - else data = json; - - $('#ypopup').empty(); - - var total = data.channels[0].totalResults.replace(/[,.]/,""); - var page = (data.channels[0].startIndex / data.channels[0].itemsPerPage) + 1; - var start = startRecord + 1; - var end = startRecord + maximumRecords; - - $("div .ybpane").remove(); - var ylogo = "
"+yconf.logo+"
"; - var yresult = "
Displaying result "+start+" to "+end+"
of "+total+" total results.
"; - $("div .ui-dialog-buttonpane").prepend(ylogo+yresult); - - $.each ( - data.channels[0].items, - function(i,item) { - if (item) { - var title = "

"+item.title+"

"; - var url = "

"+item.link+"

" - var desc = "

"+item.description+"

"; - var date = "

"+item.pubDate.substring(0,16); - var size = " | "+item.sizename+"

"; - $(title+desc+url+date+size).appendTo("#ypopup"); - } - } - ); - $(".linktitle a").faviconize({ - position: "before", - defaultImage: yconf.url + "/yacy/ui/img-2/article.png", - className: "favicon" - }); - } - ); + $('#ysearch').submit(function() { + submit = true; + yacysearch(yconf.global); return false; }); -}); \ No newline at end of file +}); +function yacysearch(global) { + var url = yconf.url + '/yacysearch.json?callback=?' + $('#ypopup').empty(); + $('#ypopup').append("

Loading: "+yconf.url+"

"); + + if (!$("#ypopup").dialog('isOpen')) { + $("#ypopup").dialog('open'); + } + $("#yquery").focus(); + var param = []; + $("#ysearch input").each(function(i){ + var item = { name : $(this).attr('name'), value : $(this).attr('value') }; + if(global && (item.name == 'resource')) item.value = 'global'; + param[i] = item; + }); + param[param.length] = { name : 'startRecord', value : startRecord }; + $.getJSON(url, param, + function(json, status){ + if (json[0]) data = json[0]; + else data = json; + $('#ypopup').empty(); + 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 start = startRecord + 1; + var end = startRecord + maximumRecords; + $("div .ybpane").remove(); + if(global) var result = 'global'; + else var result = 'local'; + var ylogo = "
"+yconf.logo+"
"; + var yresult = "
Displaying result "+start+" to "+end+"
of "+total+" "+result+" results.
"; + $("div .ui-dialog-buttonpane").prepend(ylogo+yresult); + + $.each ( + data.channels[0].items, + function(i,item) { + if (item) { + var title = "

"+item.title+"

"; + var url = "

"+item.link+"

" + var desc = "

"+item.description+"

"; + var date = "

"+item.pubDate.substring(0,16); + var size = " | "+item.sizename+"

"; + $(title+desc+url+date+size).appendTo("#ypopup"); + } + } + ); + $(".linktitle a").faviconize({ + position: "before", + defaultImage: yconf.url + "/yacy/ui/img-2/article.png", + className: "favicon" + }); + } + ); +} \ No newline at end of file diff --git a/htroot/yacy/ui/yacyui-portaltest.html b/htroot/yacy/ui/yacyui-portaltest.html index f1ffbcc36..860eb1cec 100644 --- a/htroot/yacy/ui/yacyui-portaltest.html +++ b/htroot/yacy/ui/yacyui-portaltest.html @@ -8,7 +8,8 @@