function yacysearch(a){function g(a,b){var c=a.length;var d=$("#yquery").getValue();for(var e=0,f=c;e'+a[e]+"
").appendTo(b);else a.splice(e,1)}}function f(){window.setTimeout(function(){if($("#ypopup .yloading").length==0){if($("#yquery").getValue()==ycurr){$("#yside").dialog("open");$("#yquery").focus()}}},1e3)}var b=yconf.url+"/yacysearch.json?callback=?";if(a){$("#ypopup").empty();var c="

Loading: "+yconf.url+"
";var d="

";$("#ypopup").append(c+d);if(!$("#ypopup").dialog("isOpen"))$("#ypopup").dialog("open");else if($("#yside").dialog("isOpen"))$("#yside").dialog("close");$("#yquery").focus()}var e=[];$("#ysearch input").each(function(a){var b={name:$(this).attr("name"),value:$(this).attr("value")};if(b.name=="resource"){if(global)b.value="global";else{b.value="local"}}if(b.name=="query"||b.name=="search"){b.value=$.trim(b.value);if(b.value!=ycurr)ycurr=b.value}e[a]=b});e[e.length]={name:"startRecord",value:startRecord};$.ajaxSetup({timeout:1e4,error:function(b,c){var d="Unknow Error: "+b.responseText;if(b.status==0){d="Unknown Network Error! I try to reload...";yacysearch(true)}else if(b.status==404){d=b.status+" - Requested URL not found."}else if(b.status==500){d=b.status+" - Internel Server Error."}else if(c=="parsererror"){d="Parsing JSON Request failed."}else if(c=="timeout"){d="Request Time out."}if(a)$("#ypopup").empty();var e="";var f="

"+e+" "+d+"

";var g="

Current search terms: "+ycurr+"

";$(f+g).appendTo("#ypopup")}});$.getJSON(b,e,function(b,c){if(b[0])data=b[0];else data=b;var d="";d=data.channels[0].searchTerms;if($.trim(ycurr.replace(/ /g,"+"))!=d){return false}if(a){$("#ypopup").empty()}var e=data.channels[0].totalResults;if(global)var h="global";else var h="local";var i=0;$.each(data.channels[0].items,function(a,b){if(b){var c="";var d="

"+c+""+b.title+"

";var e="

"+b.link+"

";var f="

"+b.description+"

";var g="

"+b.pubDate.substring(0,16);var h=" | "+b.sizename+"

";$(d+f+e+g+h).appendTo("#ypopup")}i++});if(i==0){if(a)$("#ypopup").empty();var j="";var k="

"+j+"No search results!

";var l="

Current search terms: "+d+"

";var m="

You could restate your search, release some navigators or switch to global search...

";$(k+m+l).appendTo("#ypopup")}if(a){$("#yside").empty();var n=""+yconf.logo+"";var o="Total "+h+" results: "+e;$("
").appendTo("#yside");var p='selected="selected">';var q='";$(d).appendTo(c)});$(c).combobox({selected:function(a,b){var c=unescape($("#yquery").getValue()+" "+b.item.value);$("#yquery").setValue(c);ynavigators.push(b.item.value);$("#yquery").trigger("submit")}})}});$("
").appendTo("#yside");if(ynavigators.length>0){$("

Uncheck to release navigators:

").appendTo("#yside")}g(ynavigators,"#yside");if($("#ypopup .yloading").length==0){$(".ynav-cancel").bind("change",function(a){var b=$("#yquery").getValue();var c=$(a.target).val();var d=ynavigators.indexOf($.trim(c));if(d!=-1)ynavigators.splice(d,1);var e=new RegExp(" "+c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"));$("#yquery").setValue($.trim(b.replace(e,"")));startRecord=0;$("#yquery").trigger("submit")});f();if($("#ypopup").dialog("isOpen")){if($("#ypopup h3 :last").position().top<$("#ypopup").dialog("option","height")&&i==maximumRecords){startRecord=startRecord+maximumRecords;yacysearch(false)}}}}})}function yrun(){maximumRecords=parseInt($("#ysearch input[name='maximumRecords']").getValue());global=yconf.global;$("#ypopup").dialog({autoOpen:false,height:yconf.height,width:yconf.width,minWidth:yconf.width,position:yconf.position,modal:yconf.modal,resizable:yconf.resizable,title:yconf.title,show:yconf.show,hide:yconf.hide,drag:function(a,b){var c=$("#ypopup").parent(".ui-dialog").position();var d=$("#ypopup").parent(".ui-dialog").width()+5+c.left;$("#yside").dialog("option","position",[d,c.top+32])},dragStop:function(a,b){var c=$("#ypopup").parent(".ui-dialog").position();var d=$("#ypopup").parent(".ui-dialog").width()+5+c.left;$("#yside").dialog("option","position",[d,c.top+32])},resizeStop:function(a,b){var c=$("#ypopup").parent(".ui-dialog").position();var d=$("#ypopup").parent(".ui-dialog").height()-55;var e=$("#ypopup").parent(".ui-dialog").width()+5+c.left;$("#yside").dialog("option","height",d);$("#yside").dialog("option","position",[e,c.top+32])},close:function(a,b){$("#yquery").setValue("");$("#yside").dialog("destroy");$("#yside").remove()},open:function(a,b){$('
').insertAfter("#ypopup").parent(".ui-dialog-content");var c=$("#ypopup").parent(".ui-dialog").position();$("#yside").dialog({title:"Navigation",autoOpen:false,draggable:false,resizable:false,width:220,height:$("#ypopup").parent(".ui-dialog").height()-55,minHeight:$("#ypopup").parent(".ui-dialog").height()-55,show:"slide",hide:"slide",position:[c.left+$("#ypopup").parent(".ui-dialog").width()+5,c.top+32],open:function(a,b){$("div.ui-widget-shadow").remove();$("#ypopup").dialog("moveToTop")}});$(".ui-widget-shadow").remove();$('div[aria-labelledby="ui-dialog-title-yside"] div.ui-dialog-titlebar').remove();$("#ypopup").bind("scroll",function(a){p1=$("#ypopup h3 :last").position().top;if(p1-$("#ypopup").dialog("option","height")<0){startRecord=startRecord+maximumRecords;yacysearch(false)}})}});$("#ysearch").keyup(function(a){if(a.which==27){$("#ypopup").dialog("close");$("#yquery").setValue("")}if(a.which==18){global=true;ycurr=$("#yquery").getValue();yacysearch(true)}if(ycurr==$("#yquery").getValue()){return false}global=yconf.global;if($("#yquery").getValue()==""){if($("#ypopup").dialog("isOpen"))$("#ypopup").dialog("close")}else{ycurr=$("#yquery").getValue();yacysearch(true)}return false});$("#ysearch").submit(function(){ycurr=$("#yquery").getValue();if(!$("#ypopup").dialog("isOpen"))$("#ypopup").dialog("open");else if($("#yside").dialog("isOpen"))$("#yside").dialog("close");$("#yquery").focus();yacysearch(true);return false})}function statuscheck(){if(load_status<5){return}else{window.clearInterval(loading);yrun()}}$(document).ready(function(){ynavigators=new Array;$.ajaxSetup({timeout:5e3,cache:true});ycurr="";startRecord=0;maximumRecords=10;submit=false;yconf=$.extend({url:"",global:false,theme:"start",title:"YaCy Search Widget",logo:yconf.url+"/yacy/ui/img/yacy-logo.png",link:"http://yacy.net",width:640,height:640,position:[150,50],modal:false,resizable:true,show:"",hide:"",load_js:true,load_css:true},yconf);$('
').appendTo("#yacylivesearch");if(yconf.load_css){var a=yconf.url+"/portalsearch/yacy-portalsearch.css";var b=yconf.url+"/jquery/themes/"+yconf.theme+"/jquery-ui-1.8.16.custom.css";var c=yconf.url+"/jquery/css/jquery-ui-combobox.css";var d=document.getElementsByTagName("head")[0];$(document.createElement("link")).attr({type:"text/css",href:a,rel:"stylesheet",media:"screen"}).appendTo(d);$(document.createElement("link")).attr({type:"text/css",href:b,rel:"stylesheet",media:"screen"}).appendTo(d);$(document.createElement("link")).attr({type:"text/css",href:c,rel:"stylesheet",media:"screen"}).appendTo(d)}load_status=0;loading=window.setInterval("statuscheck()",200);if(yconf.load_js){var e=yconf.url+"/jquery/js/jquery.query-2.1.7.js";var f=yconf.url+"/jquery/js/jquery.form-2.73.js";var g=yconf.url+"/jquery/js/jquery.field-0.9.2.min.js";var h=yconf.url+"/jquery/js/jquery-ui-1.8.16.custom.min.js";var i=yconf.url+"/jquery/js/jquery-ui-combobox.js";$.getScript(e,function(){load_status++});$.getScript(f,function(){load_status++});$.getScript(g,function(){load_status++});$.getScript(h,function(){load_status++});$.getScript(i,function(){load_status++})}else{yrun()}})
"+n+""+o+"