show progress of search after display of results is finished

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7712 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2011-05-13 06:20:00 +00:00
parent 8b63d7637d
commit fcd4b03892
6 changed files with 86 additions and 4 deletions

View File

@ -71,8 +71,8 @@ function addHover() {
}
function statistics(offset, itemscount, totalcount, localResourceSize, remoteResourceSize, remoteIndexCount, remotePeerCount) {
document.getElementById("resultsOffset").firstChild.nodeValue = offset;
document.getElementById("itemscount").firstChild.nodeValue = itemscount;
if (offset >= 0) document.getElementById("resultsOffset").firstChild.nodeValue = offset;
if (itemscount >= 0) document.getElementById("itemscount").firstChild.nodeValue = itemscount;
document.getElementById("totalcount").firstChild.nodeValue = totalcount;
if (document.getElementById("localResourceSize") == null) return;
document.getElementById("localResourceSize").firstChild.nodeValue = localResourceSize;

View File

@ -39,7 +39,7 @@ public class opensearchdescription {
String promoteSearchPageGreeting = env.getConfig(SwitchboardConstants.GREETING, "");
if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
String thisaddress = header.get("Host", "localhost");
String thisaddress = header.get("Host", "127.0.0.1");
if (thisaddress.indexOf(':') == -1) thisaddress += ":" + serverCore.getPortNr(env.getConfig("port", "8090"));
int compareyacy = 0;

View File

@ -25,6 +25,6 @@
<Query role="example" searchTerms="yacy+open+source" />
<Tags>YaCy Open Source P2P Web Search</Tags>
<Contact>See http://#[thisaddress]#/ViewProfile.html?hash=localhash</Contact>
<Attribution>YaCy Software &amp;copy; 2004-2010 by Michael Christen et al., YaCy.net; Content: ask peer owner</Attribution>
<Attribution>YaCy Software &amp;copy; 2004-2011 by Michael Christen et al., YaCy.net; Content: ask peer owner</Attribution>
<SyndicationRight>open</SyndicationRight>
</OpenSearchDescription>

View File

@ -213,5 +213,36 @@ var progressbar = new Progressbar(#[results]#, document.getElementById("results"
<!--#include virtual="yacysearchtrailer.html?eventID=#[eventID]#" -->
<!-- /div -->
</div>
<!-- update the search results statistics after the search is finished -->
<script type="text/javascript">
function latestinfo() {
if (window.XMLHttpRequest) { // Mozilla/Safari
self.xmlHttpReq = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', "yacysearchlatestinfo.json?eventID=#[eventID]#", true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
var rsp = eval("(" + self.xmlHttpReq.responseText + ")");
statistics(rsp.offset, rsp.itemscount, rsp.totalcount, rsp.localResourceSize, rsp.remoteResourceSize, rsp.remoteIndexCount, rsp.remotePeerCount);
}
}
self.xmlHttpReq.send(null);
}
window.setTimeout('latestinfo();',500);
window.setTimeout('latestinfo();',1000);
window.setTimeout('latestinfo();',1500);
window.setTimeout('latestinfo();',2000);
window.setTimeout('latestinfo();',3000);
window.setTimeout('latestinfo();',4000);
window.setTimeout('latestinfo();',5000);
window.setTimeout('latestinfo();',6000);
window.setTimeout('latestinfo();',8000);
window.setTimeout('latestinfo();',10000);
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.util.Formatter;
import de.anomic.search.QueryParams;
import de.anomic.search.SearchEvent;
import de.anomic.search.SearchEventCache;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class yacysearchlatestinfo {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
//Switchboard sb = (Switchboard) env;
// find search event
final String eventID = post.get("eventID", "");
final SearchEvent theSearch = SearchEventCache.getEvent(eventID);
if (theSearch == null) {
// the event does not exist, show empty page
return prop;
}
final QueryParams theQuery = theSearch.getQuery();
//if (sb.isGlobalMode() && !theQuery.isLocal()) try {Thread.sleep(1000);} catch (InterruptedException e) {}
// dynamically update count values
final int totalcount = theSearch.getRankingResult().getLocalIndexCount() - theSearch.getRankingResult().getMissCount() - theSearch.getRankingResult().getSortOutCount() + theSearch.getRankingResult().getRemoteIndexCount();
final int offset = theQuery.neededResults() - theQuery.displayResults() + 1;
prop.put("offset", offset);
prop.put("itemscount", -1);
prop.put("totalcount", Formatter.number(totalcount, true));
prop.put("localResourceSize", Formatter.number(theSearch.getRankingResult().getLocalIndexCount(), true));
prop.put("localMissCount", Formatter.number(theSearch.getRankingResult().getMissCount(), true));
prop.put("remoteResourceSize", Formatter.number(theSearch.getRankingResult().getRemoteResourceSize(), true));
prop.put("remoteIndexCount", Formatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));
prop.put("remotePeerCount", Formatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));
return prop;
}
}

View File

@ -0,0 +1,9 @@
{
"itemscount": "#[itemscount]#",
"totalcount": "#[totalcount]#",
"localResourceSize": "#[localResourceSize]#",
"localMissCount": "#[localMissCount]#",
"remoteResourceSize": "#[remoteResourceSize]#",
"remoteIndexCount": "#[remoteIndexCount]#",
"remotePeerCount": "#[remotePeerCount]#"
}