You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yacy_search_server/htroot/js/WatchCrawler.js

294 lines
9.2 KiB

DELETE_STRING="delete"
var statusRPC;
var queuesRPC;
function requestStatus(){
statusRPC=createRequestObject()
statusRPC.open('get', '/xml/status_p.xml');
statusRPC.onreadystatechange = handleStatus;
statusRPC.send(null)
}
function requestQueues(){
queuesRPC=createRequestObject()
queuesRPC.open('get', '/xml/queues_p.xml');
queuesRPC.onreadystatechange = handleQueues;
queuesRPC.send(null);
}
window.setInterval("requestStatus()", 5000);
window.setInterval("requestQueues()", 5000);
function handleStatus(){
if(statusRPC.readyState != 4){
return;
}
var statusResponse = statusRPC.responseXML;
/*indexingqueue=statusResponse.getElementsByTagName("indexingqueue")[0];
indexingqueue_size=indexingqueue.firstChild.nextSibling;
indexingqueue_max=indexingqueue_size.nextSibling.nextSibling;
ppm=statusResponse.getElementsByTagName("ppm")[0];*/
statusTag=getFirstChild(getFirstChild(statusResponse, ""), "status")
indexingqueue=getFirstChild(statusTag, "indexingqueue");
indexingqueue_size=getValue(getFirstChild(indexingqueue, "size"));
indexingqueue_max=getValue(getFirstChild(indexingqueue, "max"));
ppm=getValue(getFirstChild(statusTag, "ppm"))
document.getElementById("indexingqueuesize").firstChild.nodeValue=indexingqueue_size;
document.getElementById("indexingqueuemax").firstChild.nodeValue=indexingqueue_max;
document.getElementById("ppm").firstChild.nodeValue=ppm;
}
function handleQueues(){
if(queuesRPC.readyState != 4){
return;
}
var queuesResponse = queuesRPC.responseXML;
xml=getFirstChild(queuesResponse);
if(queuesResponse != null){
createIndexingTable(getFirstChild(xml, "indexingqueue"));
createLoaderTable(getFirstChild(xml, "loaderqueue"));
createLocalCrawlerTable(getFirstChild(xml, "localcrawlerqueue"));
createRemoteCrawlerTable(getFirstChild(xml, "remotecrawlerqueue"));
}
}
function clearTable(table, numSkip){
if(numSkip==null){
numSkip=0;
}
row=getFirstChild(getFirstChild(table, "tbody"), "tr");
//skip numSkip rows
for(i=0;i<numSkip;i++){
row=getNextSibling(row, "tr");
}
while(row != null){ //delete old entries
getFirstChild(table, "tbody").removeChild(row);
row=getFirstChild(getFirstChild(table, "tbody"), "tr");
//skip numSkip rows
for(i=0;i<numSkip;i++){
row=getNextSibling(row, "tr");
}
}
}
function createLoaderTable(loaderqueue){
entries=loaderqueue.getElementsByTagName("entry");
loaderTable=document.getElementById("loaderTable");
clearTable(loaderTable, 1);
dark=false;
for(i=0;i<entries.length;i++){
initiator=getValue(getFirstChild(entries[i], "initiator"));
depth=getValue(getFirstChild(entries[i], "depth"));
modified=getValue(getFirstChild(entries[i], "modified"));
anchor=getValue(getFirstChild(entries[i], "anchor"));
url=getValue(getFirstChild(entries[i], "url"));
row=createLoaderRow(initiator, depth, modified, anchor, url);
//create row
if(dark){
row.setAttribute("class", "TableCellDark");
}else{
row.setAttribute("class", "TableCellLight");
}
getFirstChild(loaderTable, "tbody").appendChild(row);
dark=!dark;
}
}
function createIndexingTable(indexingqueue){
indexingTable=document.getElementById("indexingTable");
entries=indexingqueue.getElementsByTagName("entry");
clearTable(indexingTable, 1);
dark=false;
for(i=0;i<entries.length;i++){
initiator=getValue(getFirstChild(entries[i], "initiator"));
depth=getValue(getFirstChild(entries[i], "depth"));
modified=getValue(getFirstChild(entries[i], "modified"));
anchor=getValue(getFirstChild(entries[i], "anchor"));
url=getValue(getFirstChild(entries[i], "url"));
size=getValue(getFirstChild(entries[i], "size"));
hash=getValue(getFirstChild(entries[i], "hash"));
inProcess=false;
if(getValue(getFirstChild(entries[i], "inProcess"))=="true"){
inProcess=true;
}
row=createIndexingRow(initiator, depth, modified, anchor, url, size, hash);
//create row
if(inProcess){
row.setAttribute("class", "TableCellActive");
}else if(dark){
row.setAttribute("class", "TableCellDark");
}else{
row.setAttribute("class", "TableCellLight");
}
getFirstChild(indexingTable, "tbody").appendChild(row);
dark=!dark;
}
}
function createLocalCrawlerTable(localcrawlerqueue){
localCrawlerTable=document.getElementById("localCrawlerTable");
entries=localcrawlerqueue.getElementsByTagName("entry");
clearTable(localCrawlerTable, 1);
dark=false;
for(i=0;i<entries.length;i++){
initiator=getValue(getFirstChild(entries[i], "initiator"));
depth=getValue(getFirstChild(entries[i], "depth"));
modified=getValue(getFirstChild(entries[i], "modified"));
anchor=getValue(getFirstChild(entries[i], "anchor"));
url=getValue(getFirstChild(entries[i], "url"));
//hash=getValue(getFirstChild(entries[i], "hash"));
inProcess=false;
if(getValue(getFirstChild(entries[i], "inProcess"))=="true"){
inProcess=true;
}
row=createLocalCrawlerRow(initiator, depth, modified, anchor, url);
//create row
if(inProcess){
row.setAttribute("class", "TableCellActive");
}else if(dark){
row.setAttribute("class", "TableCellDark");
}else{
row.setAttribute("class", "TableCellLight");
}
getFirstChild(localCrawlerTable, "tbody").appendChild(row);
dark=!dark;
}
}
function createRemoteCrawlerTable(remotecrawlerqueue){
remoteCrawlerTable=document.getElementById("remoteCrawlerTable");
entries=remotecrawlerqueue.getElementsByTagName("entry");
clearTable(remoteCrawlerTable, 1);
dark=false;
for(i=0;i<entries.length;i++){
profile=getValue(getFirstChild(entries[i], "profile"));
depth=getValue(getFirstChild(entries[i], "depth"));
modified=getValue(getFirstChild(entries[i], "modified"));
anchor=getValue(getFirstChild(entries[i], "anchor"));
url=getValue(getFirstChild(entries[i], "url"));
//hash=getValue(getFirstChild(entries[i], "hash"));
inProcess=false;
if(getValue(getFirstChild(entries[i], "inProcess"))=="true"){
inProcess=true;
}
row=createRemoteCrawlerRow(profile, depth, modified, anchor, url);
//create row
if(inProcess){
row.setAttribute("class", "TableCellActive");
}else if(dark){
row.setAttribute("class", "TableCellDark");
}else{
row.setAttribute("class", "TableCellLight");
}
getFirstChild(remoteCrawlerTable, "tbody").appendChild(row);
dark=!dark;
}
}
function getValue(element){
if(element == null){
return "";
}else if(element.nodeType == 3){ //Textnode
return element.nodeValue;
}else if(element.firstChild != null && element.firstChild.nodeType == 3){
return element.firstChild.nodeValue;
}
return "";
}
function getFirstChild(element, childname){
if(childname==null){
childname="";
}
if(element == null){
return null;
}
child=element.firstChild;
while(child != null){
if(child.nodeType!=3 && (child.nodeName.toLowerCase()==childname.toLowerCase() || childname=="")){
return child;
}
child=child.nextSibling;
}
return null;
}
function getNextSibling(element, childname){
if(childname==null){
childname="";
}
if(element == null){
return null;
}
child=element.nextSibling;
while(child != null){
if(child.nodeType==1 && (child.nodeName.toLowerCase()==childname.toLowerCase() || childname=="")){
return child;
}
child=child.nextSibling;
}
return null;
}
function createCol(content){
col=document.createElement("td");
text=document.createTextNode(content);
col.appendChild(text);
return col;
}
function createIndexingRow(initiator, depth, modified, anchor, url, size, hash){
row=document.createElement("tr");
row.appendChild(createCol(initiator));
row.appendChild(createCol(depth));
row.appendChild(createCol(modified));
row.appendChild(createCol(anchor));
row.appendChild(createLinkCol(url, url));
row.appendChild(createCol(size));
row.appendChild(createLinkCol("IndexCreateIndexingQueue_p.html?deleteEntry="+hash, DELETE_STRING));
return row;
}
function createLoaderRow(initiator, depth, modified, anchor, url){
row=document.createElement("tr");
row.appendChild(createCol(initiator));
row.appendChild(createCol(depth));
row.appendChild(createCol(modified));
row.appendChild(createCol(anchor));
row.appendChild(createLinkCol(url, url));
return row;
}
function createLocalCrawlerRow(initiator, depth, modified, anchor, url){
row=document.createElement("tr");
row.appendChild(createCol(initiator));
row.appendChild(createCol(depth));
row.appendChild(createCol(modified));
row.appendChild(createCol(anchor));
row.appendChild(createLinkCol(url, url));
return row;
}
function createRemoteCrawlerRow(profile, depth, modified, anchor, url){
row=document.createElement("tr");
row.appendChild(createCol(profile));
row.appendChild(createCol(depth));
row.appendChild(createCol(modified));
row.appendChild(createCol(anchor));
row.appendChild(createLinkCol(url, url));
return row;
}
function createLinkCol(url, linktext){
col=document.createElement("td");
link=document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("target", "_blank");
text=document.createTextNode(linktext);
link.appendChild(text);
col.appendChild(link)
return col
}