Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

enhanced interactive search

orbiter86763c42c430
diff --git a/htroot/yacyinteractive.html b/htroot/yacyinteractive.html
index 46f4ac55d..ecfa6ad24 100644
--- a/htroot/yacyinteractive.html
+++ b/htroot/yacyinteractive.html
@@ -5,6 +5,12 @@
#%env/templates/metas.template%#
<script language="Javascript">
function xmlhttpPost() {
+
+ var searchform = document.forms['searchform'];
+ search(searchform.query.value);
+}
+
+function search(query) {
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) { // Mozilla/Safari
@@ -13,8 +19,7 @@ function xmlhttpPost() {
else if (window.ActiveXObject) { // IE
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
- var searchform = document.forms['searchform'];
- self.xmlHttpReq.open('GET', "yacysearch.json?verify=false&resource=local&maximumRecords=100&query=" + searchform.query.value, true);
+ self.xmlHttpReq.open('GET', "yacysearch.json?verify=false&resource=local&maximumRecords=100&query=" + query, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
@@ -24,7 +29,7 @@ function xmlhttpPost() {
self.xmlHttpReq.send(null);
}
-function updatepage(str){
+function updatepage(str) {
var raw = document.getElementById("raw");
if (raw != null) raw.innerHTML = str;
var rsp = eval("("+str+")");
@@ -32,25 +37,42 @@ function updatepage(str){
var totalResults = firstChannel.totalResults;
var startIndex = firstChannel.startIndex;
var itemsPerPage = firstChannel.itemsPerPage;
- var html = "<br>total results = " + totalResults;
- var item;
- html += "<table class=\"networkTable\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\">";
- html += "<tr class=\"TableHeader\" valign=\"bottom\">";
- html += "<td>Name</td>";
- //html += "<td>Description</td>";
- html += "<td>Link</td></tr>";
- for (var i = 0; i < firstChannel.items.length; i++) {
- item = firstChannel.items[i];
- html += "<tr class=\"TableCellLight\"><td>"+ item.title + "</td>";
- //html += "<td>" + item.description + "</td>";
- html += "<td><a href=\"" + item.link + "\">" + item.link + "</a></td></tr>";
+
+ var html = "<span id=\"resCounter\" style=\"display: inline;\">total results = " + totalResults;
+ if (firstChannel.topwords.length > 0) {
+ var topwords = "";
+ for (var i = 0; i < firstChannel.topwords.length; i++) {
+ topwords += "<a href=\"yacyinteractive.html?query=" + firstChannel.searchTerms + "+" + firstChannel.topwords[i].word + "\">" + firstChannel.topwords[i].word + "</a> ";
+ if (i > 10) break;
+ }
+ html += "&nbsp;&nbsp;&nbsp;topwords: " + topwords;
+ }
+ html += "</span><br>";
+
+ if (totalResults > 0) {
+ var item;
+ html += "<table class=\"networkTable\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"99%\">";
+ html += "<tr class=\"TableHeader\" valign=\"bottom\">";
+ html += "<td width=\"30%\">Name</td>";
+ //html += "<td>Description</td>";
+ html += "<td>Link</td></tr>";
+ for (var i = 0; i < firstChannel.items.length; i++) {
+ item = firstChannel.items[i];
+ html += "<tr class=\"TableCellLight\"><td>"+ item.title + "</td>";
+ //html += "<td>" + item.description + "</td>";
+ html += "<td><a href=\"" + item.link + "\">" + item.link + "</a></td></tr>";
+ }
+ html += "</table>";
}
- html += "</table>";
document.getElementById("searchresults").innerHTML = html;
}
</script>
</head>
<body>
+<script type="text/javascript">
+var q = "#[query]#";
+if (q != "") search(q);
+</script>
#(display)#
#%env/templates/simpleheader.template%#
::
@@ -64,16 +86,16 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
#%env/templates/embeddedheader.template%#
#(/display)#
-
<form class="search small" name="searchform" onkeyup='xmlhttpPost(); return false;'>
<h2>#[promoteSearchPageGreeting]#</h2>
<div class="yacylogo">
- <a href="#[promoteSearchPageGreeting.homepage]#" class="yacylogo"><img src="#[promoteSearchPageGreeting.smallImage]#" alt="yacysearch" align="left"/></a></div>
- <fieldset class="yacys"><input name="query" type="text" size="50" maxlength="80" /></fieldset>
- <div id="searchresults"></div>
+ <a href="#[promoteSearchPageGreeting.homepage]#" class="yacylogo"><img src="#[promoteSearchPageGreeting.smallImage]#" alt="yacysearch" align="left"/></a>
</div>
+ <fieldset class="yacys"><input name="query" type="text" value="#[query]#" size="50" maxlength="80" /></fieldset>
+
<!--<pre>Raw JSON String: <div id="raw"></div></pre>-->
</form>
+<div id="searchresults"></div>
#%env/templates/footer.template%#
</body>
diff --git a/htroot/yacyinteractive.java b/htroot/yacyinteractive.java
index f97b80991..52f5b58f0 100644
--- a/htroot/yacyinteractive.java
+++ b/htroot/yacyinteractive.java
@@ -50,8 +50,11 @@ public class yacyinteractive {
prop.put("promoteSearchPageGreeting", promoteSearchPageGreeting);
prop.put("promoteSearchPageGreeting.homepage", sb.getConfig(plasmaSwitchboardConstants.GREETING_HOMEPAGE, ""));
prop.put("promoteSearchPageGreeting.smallImage", sb.getConfig(plasmaSwitchboardConstants.GREETING_SMALL_IMAGE, ""));
-
prop.put("display", display);
+
+ String query = (post == null) ? "" : post.get("query", "");
+ prop.putHTML("query", query);
+ prop.putHTML("querys", query.replaceAll(" ", "+"));
return prop;
}
}
\ No newline at end of file
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 85fdd0537..d1cfdfc35 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -509,7 +509,7 @@ public class yacysearch {
// for RSS: don't HTML encode some elements
prop.putXML("rss_query", querystring);
- prop.put("rss_queryenc", yacyURL.escape(querystring.replace(' ', '+')));
+ prop.put("rss_queryenc", querystring.replace(' ', '+'));
sb.localSearchLastAccess = System.currentTimeMillis();
diff --git a/htroot/yacysearchtrailer.json b/htroot/yacysearchtrailer.json
index a01430cd8..ec4194ac3 100644
--- a/htroot/yacysearchtrailer.json
+++ b/htroot/yacysearchtrailer.json
@@ -1,4 +1,4 @@
-"yacy$topwords": [
+"topwords": [
#{words}#
{ "word": "#[word]#" }#(nl)#::,#(/nl)#
#{/words}#