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/portalsearch/yacy-portalsearch.js

1 line
10 KiB

function yacysearch(a){function g(a,b){var c=a.length;var d=$("#yquery").getValue();for(var e=0,f=c;e<f;++e){if(d.indexOf(a[e])!=-1)$(' <input type="checkbox" checked="checked" class="ynav-cancel" name="ynav'+e+'" value="'+a[e]+'"><span class="ytxt">'+a[e]+"</span><br>").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="<div class='yloading'><h3 class='linktitle'><em>Loading: "+yconf.url+"</em><br/>";var d="<img src='"+yconf.url+"/yacy/ui/img/loading2.gif' align='absmiddle'/></h3></div>";$("#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="<img src='"+yconf.url+"/yacy/ui/img-2/stop.png' class='favicon'/>";var f="<h3 class='linktitle'>"+e+" "+d+"</h3>";var g="<p class='url'><a href=''>Current search terms: "+ycurr+"</a></p>";$(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="<img src='"+yconf.url+"/ViewImage.png?width=16&height=16&code="+b.faviconCode+"' class='favicon'/>";var d="<h3 class='linktitle'>"+c+"<a href='"+b.link+"' target='_blank'>"+b.title+"</a></h3>";var e="<p class='url'><a href='"+b.link+"' target='_blank'>"+b.link+"</a></p>";var f="<p class='desc'>"+b.description+"</p>";var g="<p class='date'>"+b.pubDate.substring(0,16);var h=" | "+b.sizename+"</p>";$(d+f+e+g+h).appendTo("#ypopup")}i++});if(i==0){if(a)$("#ypopup").empty();var j="<img src='"+yconf.url+"/yacy/ui/img-2/stop.png' class='favicon'/>";var k="<h3 class='linktitle'>"+j+"No search results!</h3>";var l="<p class='url'><a href=''>Current search terms: "+d+"</a></p>";var m="<p class='desc'>You could restate your search, release some navigators or switch to global search...</p>";$(k+m+l).appendTo("#ypopup")}if(a){$("#yside").empty();var n="<a href='"+yconf.link+"' target='_blank'><img style='padding-left: 24px;' src='"+yconf.logo+"' alt='"+yconf.logo+"' title='"+yconf.logo+"' /></a>";var o="Total "+h+" results: "+e;$("<div class='ymsg'><table><tr><td width='55px'>"+n+"</td><td id='yresult'>"+o+"</td></tr></div").appendTo("#yside");$("<hr />").appendTo("#yside");var p='selected="selected">';var q='<select class="selector" id="yglobal"><option value="local"';var r='local</option><option value="global"';var s="global</option></select>";if(global){select=q+">"+r+p+s}else{select=q+p+r+">"+s}$('<div class="ui-widget ynav"><label for="yglobal">Get local/global results:</label><br />'+select+"</div>").appendTo("#yside");$("#yglobal").combobox({selected:function(a,b){if(b.item.value=="global"){global=true}else{global=false}yacysearch(true)}});q='<select class="selector" id="yrecent"><option value="relevance"';r='Relevance</option><option value="date"';s="Date</option></select>";var t=unescape($("#yquery").getValue());if(t.indexOf("/date")!=-1){select=q+">"+r+p+s}else{select=q+