DELETE _STRING = "delete" ;
BAR _IMG1 = "/env/grafics/green-block.png" ;
BAR _IMG2 = "/env/grafics/red-block.png" ;
WORDCACHEBAR _LENGTH = 1 / 4 ;
var statusRPC ;
var refreshInterval = 2 ;
var wait = 0 ;
var changing = false ; //change the interval
var statusLoaded = true ;
function initCrawler ( ) {
refresh ( ) ;
//loadInterval=window.setInterval("refresh()", refreshInterval*1000);
countInterval = window . setInterval ( "countdown()" , 1000 ) ;
}
function changeInterval ( ) {
if ( ! changing ) {
window . clearInterval ( countInterval ) ;
counter = document . getElementById ( "nextUpdate" ) ;
//counter.innerHTML='<input type="text" id="newInterval" onblur="newInterval()" size="2" />';
//document.getElementById("newInterval").focus();
counter . value = refreshInterval ;
changing = true ;
}
}
function newInterval ( ) {
var newInterval = document . getElementById ( "nextUpdate" ) . value ;
// make sure that only positive intervals can be set
if ( newInterval > 0 ) {
refreshInterval = newInterval ;
}
refresh ( ) ;
countInterval = window . setInterval ( "countdown()" , 1000 ) ;
changing = false ;
}
function countdown ( ) {
if ( statusLoaded ) {
wait -- ;
if ( wait == 0 ) {
refresh ( ) ;
}
}
}
function refresh ( ) {
wait = refreshInterval ;
statusLoaded = false ;
requestStatus ( ) ;
getRSS ( "/api/feed.xml?count=20&set=REMOTEINDEXING,LOCALINDEXING&time=" + ( new Date ( ) ) . getTime ( ) ) ;
}
function requestStatus ( ) {
statusRPC = createRequestObject ( ) ;
statusRPC . open ( 'get' , '/api/status_p.xml?html=' ) ;
statusRPC . onreadystatechange = handleStatus ;
statusRPC . send ( null ) ;
}
function handleStatus ( ) {
if ( statusRPC . readyState != 4 ) {
return ;
}
var statusResponse = statusRPC . responseXML ;
statusTag = getFirstChild ( statusResponse , "status" ) ;
ppm = getValue ( getFirstChild ( statusTag , "ppm" ) ) ;
var ppmNum = document . getElementById ( "ppmNum" ) ;
removeAllChildren ( ppmNum ) ;
ppmNum . appendChild ( document . createTextNode ( ppm ) ) ;
// ppmBar start
var ppmBar = document . getElementById ( "ppmbar" ) ;
var ppmBarMaxRead = document . getElementById ( "customPPM" ) ;
var ppmforppmbar = ppm . replace ( /\.*/g , "" ) ;
ppmBar . setAttribute ( "value" , ppmforppmbar ) ;
ppmBar . setAttribute ( "max" , ppmBarMaxRead . value ) ;
// ppmBar end
// traffic output (no bar up to now)
traffic = getFirstChild ( statusTag , "traffic" ) ;
trafficCrawlerValue = getValue ( getFirstChild ( traffic , "crawler" ) ) ;
trafCrawlerSpan = document . getElementById ( "trafficCrawler" ) ;
removeAllChildren ( trafCrawlerSpan ) ;
trafCrawlerSpan . appendChild ( document . createTextNode ( Math . round ( ( trafficCrawlerValue ) / 1024 / 10.24 ) / 100 ) ) ;
dbsize = getFirstChild ( statusTag , "dbsize" ) ;
urlpublictext = getValue ( getFirstChild ( dbsize , "urlpublictext" ) ) ;
urlpublictextSegmentCount = getValue ( getFirstChild ( dbsize , "urlpublictextSegmentCount" ) ) ;
webgraph = getValue ( getFirstChild ( dbsize , "webgraph" ) ) ;
webgraphSegmentCount = getValue ( getFirstChild ( dbsize , "webgraphSegmentCount" ) ) ;
citation = getValue ( getFirstChild ( dbsize , "citation" ) ) ;
citationSegmentCount = getValue ( getFirstChild ( dbsize , "citationSegmentCount" ) ) ;
rwipublictext = getValue ( getFirstChild ( dbsize , "rwipublictext" ) ) ;
rwipublictextSegmentCount = getValue ( getFirstChild ( dbsize , "rwipublictextSegmentCount" ) ) ;
document . getElementById ( "urlpublictextSize" ) . firstChild . nodeValue = urlpublictext ;
document . getElementById ( "urlpublictextSegmentCount" ) . firstChild . nodeValue = urlpublictextSegmentCount ;
document . getElementById ( "webgraphSize" ) . firstChild . nodeValue = webgraph ;
document . getElementById ( "webgraphSegmentCount" ) . firstChild . nodeValue = webgraphSegmentCount ;
document . getElementById ( "citationSize" ) . firstChild . nodeValue = citation ;
document . getElementById ( "citationSegmentCount" ) . firstChild . nodeValue = citationSegmentCount ;
document . getElementById ( "rwipublictextSize" ) . firstChild . nodeValue = rwipublictext ;
document . getElementById ( "rwipublictextSegmentCount" ) . firstChild . nodeValue = rwipublictextSegmentCount ;
postprocessing = getFirstChild ( statusTag , "postprocessing" ) ;
document . getElementById ( "postprocessing_status" ) . firstChild . nodeValue = getValue ( getFirstChild ( postprocessing , "status" ) ) ;
document . getElementById ( "postprocessing_collection" ) . firstChild . nodeValue = "pending in collection: " + getValue ( getFirstChild ( postprocessing , "collectionRemainingCount" ) ) ;
document . getElementById ( "postprocessing_webgraph" ) . firstChild . nodeValue = "pending in webgraph: " + getValue ( getFirstChild ( postprocessing , "webgraphRemainingCount" ) ) ;
document . getElementById ( "postprocessing_remainingTimeMinutes" ) . firstChild . nodeValue = getValue ( getFirstChild ( postprocessing , "remainingTimeMinutes" ) ) ;
document . getElementById ( "postprocessing_remainingTimeSeconds" ) . firstChild . nodeValue = getValue ( getFirstChild ( postprocessing , "remainingTimeSeconds" ) ) ;
postprocessingElapsedTime = getValue ( getFirstChild ( postprocessing , "postprocessingElapsedTime" ) ) ;
postprocessingRemainingTime = getValue ( getFirstChild ( postprocessing , "postprocessingRemainingTime" ) ) ;
p = 100 * postprocessingElapsedTime / ( postprocessingElapsedTime + postprocessingRemainingTime ) ;
bar = "<progress id='postprocessingBar' max='" + p + "' value='100' style='width:94%;'/>" ;
document . getElementById ( "postprocessing_bar" ) . firstChild . nodeValue = bar ;
//document.getElementById("postprocessing_speed").firstChild.nodeValue=getValue(getFirstChild(postprocessing, "speed"));
load = getFirstChild ( statusTag , "load" ) ;
document . getElementById ( "load" ) . firstChild . nodeValue = getValue ( load ) ;
loaderqueue = getFirstChild ( statusTag , "loaderqueue" ) ;
loaderqueue _size = getValue ( getFirstChild ( loaderqueue , "size" ) ) ;
loaderqueue _max = getValue ( getFirstChild ( loaderqueue , "max" ) ) ;
document . getElementById ( "loaderqueuesize" ) . firstChild . nodeValue = loaderqueue _size ;
document . getElementById ( "loaderqueuemax" ) . firstChild . nodeValue = loaderqueue _max ;
localcrawlerqueue = getFirstChild ( statusTag , "localcrawlerqueue" ) ;
localcrawlerqueue _size = getValue ( getFirstChild ( localcrawlerqueue , "size" ) ) ;
localcrawlerqueue _state = getValue ( getFirstChild ( localcrawlerqueue , "state" ) ) ;
document . getElementById ( "localcrawlerqueuesize" ) . firstChild . nodeValue = localcrawlerqueue _size ;
putQueueState ( "localcrawler" , localcrawlerqueue _state ) ;
limitcrawlerqueue = getFirstChild ( statusTag , "limitcrawlerqueue" ) ;
limitcrawlerqueue _size = getValue ( getFirstChild ( limitcrawlerqueue , "size" ) ) ;
limitcrawlerqueue _state = getValue ( getFirstChild ( limitcrawlerqueue , "state" ) ) ;
document . getElementById ( "limitcrawlerqueuesize" ) . firstChild . nodeValue = limitcrawlerqueue _size ;
putQueueState ( "limitcrawler" , limitcrawlerqueue _state ) ;
remotecrawlerqueue = getFirstChild ( statusTag , "remotecrawlerqueue" ) ;
remotecrawlerqueue _size = getValue ( getFirstChild ( remotecrawlerqueue , "size" ) ) ;
remotecrawlerqueue _state = getValue ( getFirstChild ( remotecrawlerqueue , "state" ) ) ;
document . getElementById ( "remotecrawlerqueuesize" ) . firstChild . nodeValue = remotecrawlerqueue _size ;
putQueueState ( "remotecrawler" , remotecrawlerqueue _state ) ;
noloadcrawlerqueue = getFirstChild ( statusTag , "noloadcrawlerqueue" ) ;
noloadcrawlerqueue _size = getValue ( getFirstChild ( noloadcrawlerqueue , "size" ) ) ;
noloadcrawlerqueue _state = getValue ( getFirstChild ( noloadcrawlerqueue , "state" ) ) ;
document . getElementById ( "noloadcrawlerqueuesize" ) . firstChild . nodeValue = noloadcrawlerqueue _size ;
putQueueState ( "noloadcrawler" , noloadcrawlerqueue _state ) ;
statusLoaded = true ;
}
function putQueueState ( queue , state ) {
a = document . getElementById ( queue + "stateA" ) ;
img = document . getElementById ( queue + "stateIMG" ) ;
if ( state == "paused" ) {
a . href = "Crawler_p.html?continue=" + queue ;
a . title = "Continue this queue (" + state + ")" ;
img . src = "/env/grafics/start.gif" ;
img . alt = "Continue this queue" ;
} else {
a . href = "Crawler_p.html?pause=" + queue ;
a . title = "Pause this queue (" + state + ")" ;
img . src = "/env/grafics/stop.gif" ;
img . alt = "Pause this queue" ;
}
}
function shortenURL ( url ) {
if ( url . length > 80 ) {
return url . substr ( 0 , 80 ) + "..." ;
} else {
return url ;
}
}
function createIndexingRow ( queue , profile , initiator , depth , modified , anchor , url , size , deletebutton ) {
row = document . createElement ( "tr" ) ;
row . setAttribute ( "height" , 10 ) ;
row . appendChild ( createCol ( queue ) ) ;
row . appendChild ( createCol ( profile ) ) ;
row . appendChild ( createCol ( initiator ) ) ;
row . appendChild ( createCol ( depth ) ) ;
row . appendChild ( createCol ( modified ) ) ;
row . appendChild ( createCol ( anchor ) ) ;
row . appendChild ( createLinkCol ( url , shortenURL ( url ) ) ) ;
row . appendChild ( createCol ( size ) ) ;
row . appendChild ( deletebutton ) ;
return row ;
}
crawllist _head = "<table cellpadding='2' cellspacing='1' ><tr class='TableHeader'><td width='50%'><strong>Title</strong></td><td width='50%'><strong>URL</strong></td></tr>" ;
crawllist _body = "" ;
crawllist _tail = "</table>" ;
function showRSS ( RSS ) {
var doc = document . getElementById ( "crawllist" ) ;
if ( doc != null ) {
if ( crawllist _body . length > 100000 ) crawllist _body = "" ;
for ( var i = 0 ; i < RSS . items . length ; i ++ ) {
crawllist _body = "<tr class='TableCellLight'><td><a href='ViewFile.html?action=info&urlHash=" + RSS . items [ i ] . guid . value + "' class='small' target='_blank' title='" + RSS . items [ i ] . link + "'>" + RSS . items [ i ] . description + "</a></td><td><a href='ViewFile.html?action=info&urlHash=" + RSS . items [ i ] . guid . value + "' class='small' target='_blank' title='" + RSS . items [ i ] . link + "'>" + RSS . items [ i ] . link + "</a></td></tr>" + crawllist _body ;
}
doc . innerHTML = crawllist _head + crawllist _body + crawllist _tail ;
}
return true ;
}