<%
Option Explicit
'-------------------- Functions -----------------------------------
Sub OutputTimerHead
%>
<style>
.redline{
height:10px;
width:0px;
background-color:red;
}
.greenline{
height:10px;
width:200px;
background-color:green;
}
</style>
<script>
var rl,maxSize;
function running(message){
nSize = maxSize/100 * 200;//convert to the 200 pixel width
rl.style.pixelWidth = rl.style.pixelWidth + 1;
if(rl.style.pixelWidth<=nSize)
setTimeout("running('" + message + "');",10);
else
rl.innerHTML = "<center>" + message + "</center>";
}
</script>
<%
End Sub
Sub OutputBars
%>
<div style="height:10px;width:200px;" class="greenline" id="greenline"><div id="redline" class="redline" style="height:10px;width:10px;"> </div></div>
<script language="Javascript">
rl = document.getElementById("redline")
</script>
<%
Response.Flush
End Sub
Sub IncreaseLoadBar(amt)
%>
<script language="Javascript">
maxSize = <%=amt%>;
running("<%=amt%>%");
</script>
<%
Response.Flush
End Sub
Sub DisappearTheBar
%>
<script language="Javascript">
document.getElementById("greenline").style.display="none";
</script>
<%
End Sub
'--------------------- Sample ---------------------------------
Response.Write "<html><head>"
OutputTimerHead
Response.Write "</head><body>"
Response.Write "Here we go!<br>"
OutputBars
'load the load bar to 5%
IncreaseLoadBar 5
'-- fake delay from workload
Dim tm, ttm
ttm = Now
tm = dateAdd("s",4,Now)
Response.Write "Time now: " & ttm & " calculating junk until " & tm & "<br>"
Do Until ttm > tm
ttm = Now
Loop
'-- end fake delay
'load the load bar to 25%
IncreaseLoadBar 25
'--- more fake delay
ttm = Now
tm = dateAdd("s",4,Now)
Response.Write "Time now: " & ttm & " calculating junk until " & tm & "<br>"
Do Until ttm > tm
ttm = Now
Loop
'load the load bar to 50%
IncreaseLoadBar 50
'--- more fake delay
ttm = Now
tm = dateAdd("s",4,Now)
Response.Write "Time now: " & ttm & " calculating junk until " & tm & "<br>"
Do Until ttm > tm
ttm = Now
Loop
'load the load bar to 75%
IncreaseLoadBar 75
'--- more fake delay
ttm = Now
tm = dateAdd("s",4,Now)
Response.Write "Time now: " & ttm & " calculating junk until " & tm & "<br>"
Do Until ttm > tm
ttm = Now
Loop
'load the load bar to 100%
IncreaseLoadBar 100
'get rid of the darn bar :)
DisappearTheBar
%>