diff --git a/htroot/yacy/ui/js/yacyui-portalsearch.js b/htroot/yacy/ui/js/yacyui-portalsearch.js index 6ed3152b5..4d2ff049b 100644 --- a/htroot/yacy/ui/js/yacyui-portalsearch.js +++ b/htroot/yacy/ui/js/yacyui-portalsearch.js @@ -4,6 +4,7 @@ $(document).ready(function() { cache: false }) // apply default properties + ycurr = ''; startRecord = 0; maximumRecords = 10; submit = false; @@ -202,14 +203,14 @@ function yrun() { }); } -function yacysearch(global) { +function yacysearch(global) { var url = yconf.url + '/yacysearch.json?callback=?' $('#ypopup').empty(); - $('#ypopup').append("

Loading: "+yconf.url+"

"); - - if (!$("#ypopup").dialog('isOpen')) { + $('#ypopup').append("

Loading: "+yconf.url+"

"); + if (!$("#ypopup").dialog('isOpen')) $("#ypopup").dialog('open'); - } + if ($("#yside").dialog('isOpen')) + $("#yside").dialog('close'); $("#yquery").focus(); var param = []; $("#ysearch input").each(function(i){ @@ -222,7 +223,8 @@ function yacysearch(global) { }); param[param.length] = { name : 'startRecord', value : startRecord }; $.getJSON(url, param, - function(json, status){ + function(json, status){ + ycurr = $("#yquery").getValue(); if (json[0]) data = json[0]; else data = json; $('#ypopup').empty(); @@ -236,7 +238,7 @@ function yacysearch(global) { var ylogo = "
"+yconf.logo+"
"; var yresult = "
Displaying result "+start+" to "+end+"
of "+total+" "+result+" results.
"; $('div[aria-labelledby="ui-dialog-title-ypopup"] div.ui-dialog-buttonpane').prepend(ylogo+yresult); - + var count = 0; $.each ( data.channels[0].items, function(i,item) { @@ -247,15 +249,15 @@ function yacysearch(global) { var date = "

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

"; $(title+desc+url+date+size).appendTo("#ypopup"); - } + } + count++; } ); $("#ypopup .linktitle a").faviconize({ position: "before", defaultImage: yconf.url + "/yacy/ui/img-2/article.png", className: "favicon" - }); - + }); $('#yside').empty(); $.each ( data.channels[0].navigation, @@ -278,7 +280,6 @@ function yacysearch(global) { } } ); - $('#ynav1 .ui-accordion-header').trigger('click'); $('#yside a').click(function() { var modifier = $(this).attr('modifier'); modifier = modifier.replace(/^#/,''); @@ -286,6 +287,19 @@ function yacysearch(global) { $("#yquery").setValue(query); $("#yquery").trigger('keyup'); }); + if(count>0) + autoOpenSidebar(); } ); + function autoOpenSidebar() { + window.setTimeout(function() { + if( $("#yquery").getValue() == ycurr) { + if (!$("#yside").dialog('isOpen')) { + $("#yside").dialog('open'); + $('#ynav1').accordion('activate', false); + $("#yquery").focus(); + } + } + } , 3000); + } } \ No newline at end of file