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
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IE
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('GET', "yacysearch.json?verify=false&resource=local&maximumRecords=100&nav=none&query=" + query, 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 navget(list, name) {
for (var i = 0; i < list.length; i++) {
if (list[i].facetname == name) return list[i];
}
}
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 topics = navget(navigation, "topics");
var html = "total results = " + totalResults;
if (topics && topics.length > 0) {
var topwords = "";
for (var i = 0; i < topics.elements.length; i++) {
topwords += "" + topics.elements[i].name + " ";
if (i > 10) break;
}
html += " topwords: " + topwords;
}
html += "
";
if (totalResults > 0) {
var item;
html += "
Name | "; html += "Size | "; //html += "Description | "; html += "Date |
" + item.title + " | "; html += "" + item.sizename + " | "; //html += "" + item.description + " | "; html += "" + item.pubDate + " |