2007-06-16 23:55:15 +02:00
function Progressbar ( length , parent ) {
// the number of steps of the bar
this . length = length ;
// the current position, expressed in steps (so 100% = length)
this . position = 0 ;
// the current percentage of the bar
this . percentage = 0
// use this function to display the progress, because it updates everything
this . step = function ( count ) {
2007-09-17 21:39:15 +02:00
if ( this . position < this . length )
this . position += count ;
2007-06-16 23:55:15 +02:00
// update the bar
this . percentage = this . position * ( 100 / this . length ) ;
this . fill . style . width = this . percentage + "%" ;
// if the end is reached, the bar is hidden/removed
2007-09-17 21:39:15 +02:00
if ( this . position >= this . length ) {
this . fill . style . visibility = "hidden" ;
}
2007-06-16 23:55:15 +02:00
}
// the actual progressbar
var bar = document . createElement ( "div" ) ;
2007-09-17 21:39:15 +02:00
bar . id = "resProgBar" ;
bar . className = "ProgressBar" ;
2007-06-16 23:55:15 +02:00
// the actual bar
this . fill = document . createElement ( "div" ) ;
2007-09-17 21:39:15 +02:00
this . fill . id = "resProgFill" ;
2007-06-16 23:55:15 +02:00
this . fill . className = "ProgressBarFill" ;
this . fill . style . width = "0%"
bar . appendChild ( this . fill ) ;
// the container for the elements used by the Progressbar
this . element = document . createElement ( "div" ) ;
this . element . style . textAlign = "center" ;
// get hasLayout in IE, needed because of the percentage as width of the bar
this . element . className = "gainlayout" ;
2007-09-17 21:39:15 +02:00
// results counter inside progress bar
var resCounter = document . getElementById ( "resCounter" ) ;
resCounter . style . display = "inline" ;
bar . appendChild ( resCounter ) ;
// the result sites navigation
var resNav = document . getElementById ( "resNav" ) ;
resNav . style . display = "inline" ;
bar . appendChild ( resNav ) ;
2007-06-16 23:55:15 +02:00
this . element . appendChild ( bar ) ;
parent . appendChild ( this . element ) ;
}
2006-09-16 18:56:22 +02:00
function addHover ( ) {
if ( document . all && document . getElementById ) {
var divs = document . getElementsByTagName ( "div" ) ;
for ( i = 0 ; i < divs . length ; i ++ ) {
var node = divs [ i ] ;
if ( node . className == "searchresults" ) {
node . onmouseover = function ( ) {
this . className += " hover" ;
}
node . onmouseout = function ( ) {
this . className = this . className . replace ( " hover" , "" ) ;
}
}
}
}
2007-06-09 01:59:18 +02:00
}
2007-09-04 01:43:55 +02:00
2011-06-13 23:44:03 +02:00
function statistics ( offset , itemscount , itemsperpage , totalcount , localResourceSize , remoteResourceSize , remoteIndexCount , remotePeerCount , navurlbase ) {
2011-09-21 13:01:01 +02:00
if ( totalcount == 0 ) return ;
2011-05-13 08:20:00 +02:00
if ( offset >= 0 ) document . getElementById ( "resultsOffset" ) . firstChild . nodeValue = offset ;
2011-09-21 13:01:01 +02:00
if ( itemscount >= 0 ) document . getElementById ( "itemscount" ) . firstChild . nodeValue = itemscount ;
2008-01-30 22:58:30 +01:00
document . getElementById ( "totalcount" ) . firstChild . nodeValue = totalcount ;
2009-03-06 11:16:14 +01:00
if ( document . getElementById ( "localResourceSize" ) == null ) return ;
2008-01-30 22:58:30 +01:00
document . getElementById ( "localResourceSize" ) . firstChild . nodeValue = localResourceSize ;
document . getElementById ( "remoteResourceSize" ) . firstChild . nodeValue = remoteResourceSize ;
document . getElementById ( "remoteIndexCount" ) . firstChild . nodeValue = remoteIndexCount ;
document . getElementById ( "remotePeerCount" ) . firstChild . nodeValue = remotePeerCount ;
2011-11-27 16:38:37 +01:00
document . getElementById ( "resNav" ) . firstChild . nodeValue = "X" ;
2011-06-13 23:44:03 +02:00
// compose page navigation
resnav = "" ;
2011-11-27 16:38:37 +01:00
thispage = Math . floor ( offset / itemsperpage ) ;
if ( thispage == 0 ) {
resnav += ( "<img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" /> " ) ;
} else {
resnav += ( "<a id=\"prevpage\" href=\"" ) ;
resnav += ( navurlbase + "&startRecord=" + ( ( thispage - 1 ) * itemsperpage ) ) ;
resnav += ( "\"><img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" /></a> " ) ;
}
2011-09-21 13:01:01 +02:00
2012-02-24 02:46:56 +01:00
numberofpages = Math . min ( 10 , 1 + ( ( totalcount - 1 ) / itemsperpage ) ) ;
2011-11-27 16:38:37 +01:00
if ( ! numberofpages ) numberofpages = 10 ;
for ( i = 0 ; i < numberofpages ; i ++ ) {
if ( i == thispage ) {
resnav += "<img src=\"env/grafics/navs" ;
resnav += ( i + 1 ) ;
resnav += ( ".gif\" alt=\"page" ) ;
resnav += ( i + 1 ) ;
resnav += ( "\" width=\"16\" height=\"16\" /> " ) ;
} else {
resnav += ( "<a href=\"" ) ;
resnav += ( navurlbase + "&startRecord=" + ( i * itemsperpage ) ) ;
resnav += ( "\"><img src=\"env/grafics/navd" ) ;
resnav += ( i + 1 ) ;
resnav += ( ".gif\" alt=\"page" ) ;
resnav += ( i + 1 ) ;
2012-08-20 13:02:29 +02:00
resnav += ( "\" title=\"use the TAB key to navigate to next page\" width=\"16\" height=\"16\" /></a> " ) ;
2011-11-27 16:38:37 +01:00
}
}
if ( thispage >= numberofpages ) {
2012-08-20 13:02:29 +02:00
resnav += ( "<img src=\"env/grafics/navdr.gif\" alt=\"arrowright\" title=\"use the TAB key to navigate to next page\" width=\"16\" height=\"16\" />" ) ;
2011-11-27 16:38:37 +01:00
} else {
resnav += ( "<a id=\"nextpage\" href=\"" ) ;
resnav += ( navurlbase + "&startRecord=" + ( ( thispage + 1 ) * itemsperpage ) ) ;
2012-08-20 13:02:29 +02:00
resnav += ( "\"><img src=\"env/grafics/navdr.gif\" alt=\"arrowright\" title=\"use the TAB key to navigate to next page\" width=\"16\" height=\"16\" /></a>" ) ;
2011-11-27 16:38:37 +01:00
}
document . getElementById ( "resNav" ) . innerHTML = resnav ;
2011-09-03 09:10:47 +02:00
}