summaryrefslogtreecommitdiff
path: root/htroot/ViewFile.html
diff options
context:
space:
mode:
authorMichael Peter Christen <mc@yacy.net>2012-09-11 02:03:14 +0200
committerMichael Peter Christen <mc@yacy.net>2012-09-11 02:03:14 +0200
commit9644c186a44d2b8c86cec8686f2405a67a76422a (patch)
tree7810acaa2ed7bdf83c2d348069a8d572efa1121b /htroot/ViewFile.html
parentb69ed96f0b153c2d3275dff8e01595b746a08010 (diff)
added search functionality to ViewFile.html servlet
Diffstat (limited to 'htroot/ViewFile.html')
-rw-r--r--htroot/ViewFile.html63
1 files changed, 60 insertions, 3 deletions
diff --git a/htroot/ViewFile.html b/htroot/ViewFile.html
index a44d67c6d..d72d53d3b 100644
--- a/htroot/ViewFile.html
+++ b/htroot/ViewFile.html
@@ -1,6 +1,59 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<!-- This page is only XHTML 1.0 Transitional and not Strict because iframes are in use -->
<html xmlns="http://www.w3.org/1999/xhtml">
+ <script type="text/javascript">
+//<![CDATA[
+function xmlhttpPost() {
+ var searchform = document.getElementById('searchform');
+ search(searchform.url.value);
+}
+
+function search(query) {
+ var xmlHttpReq = false;
+ var self = this;
+ if (window.XMLHttpRequest) { // Mozilla/Safari
+ self.xmlHttpReq = new XMLHttpRequest();
+ }
+ else if (window.ActiveXObject) { // IE
+ self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ self.xmlHttpReq.open('GET', "/solr/select?q=sku:\"" + query + "\" OR host_s:\"" + query + "\" OR host_dnc_s:\"" + query + "\" OR host_organization_s:\"" + query + "\" OR host_organizationdnc_s:\"" + query + "\" OR host_subdomain_s:\"" + query + "\"&start=0&rows=100&wt=json", true);
+ self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ self.xmlHttpReq.onreadystatechange = function() {
+ if (self.xmlHttpReq.readyState == 4) {
+ updatepage(self.xmlHttpReq.responseText);
+ }
+ }
+ self.xmlHttpReq.send(null);
+}
+
+function updatepage(str) {
+ var raw = document.getElementById("raw");
+ if (raw != null) raw.innerHTML = str;
+ var rsp = eval("("+str+")");
+ var firstChannel = rsp.channels[0];
+ var totalResults = firstChannel.totalResults.replace(/[,.]/,"");
+ var startIndex = firstChannel.startIndex;
+ var itemsPerPage = firstChannel.itemsPerPage;
+ var navigation = firstChannel.navigation;
+
+ var html = "";
+
+ if (totalResults > 0 && firstChannel.items.length > 0) {
+ var item;
+ html += "<table class=\"networkTable\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"99%\">";
+ html += "<tr class=\"TableHeader\" valign=\"bottom\">";
+ html += "<td>URL from index (total results = " + totalResults + ")<\/td>";
+ for (var i = 0; i < firstChannel.items.length; i++) {
+ item = firstChannel.items[i];
+ html += "<tr class=\"TableCellLight\"><td align=\"left\"><a href=\"HostBrowser.html?urlstringsearch=&amp;urlstring=" + item.link + "\">" + item.link + "<\/a><\/td>";
+ }
+ html += "<\/table>";
+ }
+ document.getElementById("searchresults").innerHTML = html;
+}
+//]]>
+</script>
<head>
<title>YaCy '#[clientname]#': View URL Content</title>
#%env/templates/metas.template%#
@@ -22,11 +75,15 @@
<h2>View URL Content</h2>
- <form method="get" action="ViewFile.html" accept-charset="ascii">
+ <form method="get" action="ViewFile.html" id="searchform" accept-charset="ascii" onkeyup="xmlhttpPost(); return false;">
<fieldset><legend>Get URL Viewer</legend>
<dl>
- <dt>URL:</dt><dd><input type="text" size="60" name="url" value="#[url]#" />&nbsp;<input type="submit" name="show" value="Show" /></dd>
- <dd>&nbsp;</dd>
+ <dt>URL:</dt>
+ <dd>
+ <input type="text" size="60" name="url" value="#[url]#" />
+ <input type="submit" name="show" value="Show" />
+ <div id="searchresults"></div>
+ </dd>
</dl>
</fieldset>
</form>