function status() { if(load_status < 4) { return; } else { window.clearInterval(loading); yrun(); } } function openNavigator(modifier) { var query = $("#yquery").getValue() + " " +modifier; $("#yquery").setValue(query); $("#yquery").trigger('keyup'); } $(document).ready(function() { $.ajaxSetup({ timeout: 5000, cache: true }) // apply default properties ycurr = ''; 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', 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 style1 = yconf.url + '/yacy/ui/css/yacyui-portalsearch.css'; var style2 = yconf.url + '/yacy/ui/css/themes/'+yconf.theme+'/ui.core.css'; var style3 = yconf.url + '/yacy/ui/css/themes/'+yconf.theme+'/ui.dialog.css'; var style4 = yconf.url + '/yacy/ui/css/themes/'+yconf.theme+'/ui.theme.css'; var style5 = yconf.url + '/yacy/ui/css/themes/'+yconf.theme+'/ui.resizable.css'; var style6 = yconf.url + '/yacy/ui/css/themes/'+yconf.theme+'/ui.accordion.css'; var head = document.getElementsByTagName('head')[0]; $(document.createElement('link')) .attr({type:'text/css', href: style1, rel:'stylesheet', media:'screen'}) .appendTo(head); $(document.createElement('link')) .attr({type:'text/css', href: style2, rel:'stylesheet', media:'screen'}) .appendTo(head); $(document.createElement('link')) .attr({type:'text/css', href: style3, rel:'stylesheet', media:'screen'}) .appendTo(head); $(document.createElement('link')) .attr({type:'text/css', href: style4, rel:'stylesheet', media:'screen'}) .appendTo(head); $(document.createElement('link')) .attr({type:'text/css', href: style5, rel:'stylesheet', media:'screen'}) .appendTo(head); $(document.createElement('link')) .attr({type:'text/css', href: style6, rel:'stylesheet', media:'screen'}) .appendTo(head); } load_status = 0; loading = window.setInterval("status()", 200); if(yconf.load_js) { var script1 = yconf.url + '/yacy/ui/js/jquery.query.js'; var script2 = yconf.url + '/yacy/ui/js/jquery.form.js'; var script3 = yconf.url + '/yacy/ui/js/jquery.field.min.js'; var script4 = yconf.url + '/yacy/ui/js/jquery-ui-1.7.2.min.js'; $.getScript(script1, function(){ load_status++; }); $.getScript(script2, function(){ load_status++; }); $.getScript(script3, function(){ load_status++; }); $.getScript(script4, function(){ load_status++; }); } else { yrun(); } }); function yrun() { $.extend($.ui.accordion.defaults, { autoHeight: false, clearStyle: true, collapsible: true, header: "h3" }); maximumRecords = parseInt($("#ysearch input[name='maximumRecords']").getValue()); $("#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, close: function(event, ui) { $("#yquery").setValue(''); }, drag: function(event, ui) { var position = $(".ui-dialog").position(); var left = $(".ui-dialog").width()+5+position.left; $("#yside").dialog('option', 'position', [left,position.top+32]); }, dragStop: function(event, ui) { var position = $(".ui-dialog").position(); var left = $(".ui-dialog").width()+5+position.left; $("#yside").dialog('option', 'position', [left,position.top+32]); }, resizeStop: function(event, ui) { var position = $(".ui-dialog").position(); var height = $(".ui-dialog").height()-55; var left = $(".ui-dialog").width()+5+position.left; $("#yside").dialog('option', 'height', height); $("#yside").dialog('option', 'position', [left,position.top+32]); }, close: function(event, ui) { $("#yside").dialog('destroy'); $('#yside').remove(); }, open: function(event, ui) { $('').insertAfter(".ui-dialog-content"); var position = $(".ui-dialog").position(); $("#yside").dialog({ title: 'Navigation', autoOpen: false, draggable: false, resizable: false, width: 220, height: $(".ui-dialog").height()-55, minHeight: $(".ui-dialog").height()-55, show: 'slide', hide: 'slide', position : [position.left+$(".ui-dialog").width()+5,position.top+32], open: function(event, ui) { $('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(e){ p1 = $("#ypopup h3 :last").position().top; if(p1-yconf.height < 0) { startRecord = startRecord + maximumRecords; yacysearch(submit, false); } }); } }); $('#ysearch').keyup(function(e) { if(ycurr == $("#yquery").getValue()) { return false; } if(e.which == 27) { // ESC $("#ypopup").dialog('close'); } else if(e.which == 34) { // PageDown startRecord = startRecord + maximumRecords; } else if(e.which == 33) { // PageUp startRecord = startRecord - maximumRecords; if(startRecord < 0) startRecord = 0; } else { startRecord = 0; } if ($("#yquery").getValue() == '') { if($("#ypopup").dialog('isOpen')) $("#ypopup").dialog('close'); } else { ycurr = $("#yquery").getValue(); if(!submit) yacysearch(false, true); else submit = false; } return false; }); $('#ysearch').submit(function() { submit = true; ycurr = $("#yquery").getValue(); if (!$("#ypopup").dialog('isOpen')) $("#ypopup").dialog('open'); else if ($("#yside").dialog('isOpen')) $("#yside").dialog('close'); $("#yquery").focus(); yacysearch(yconf.global, true); return false; }); } function yacysearch(global, clear) { var url = yconf.url + '/yacysearch.json?callback=?' if(clear) { $('#ypopup').empty(); var loading = ""+item.description+"
"; var date = ""+item.pubDate.substring(0,16); var size = " | "+item.sizename+"
"; $(title+desc+url+date+size).appendTo("#ypopup"); } count++; } ); if(clear) { $('#yside').empty(); var yglobal = "local"; if(global) yglobal = "global"; $('').appendTo('#yside'); $('"+ylogo+" | "+ymsg+" |