Next up on the platter, A slick progress bar:
Save this as progress.html:
<html>
<head>
<title>Please Wait</title>
<script type="text/javascript">
var part=0;
var whole=100;
function progress(part,whole){
if(part>=whole){
self.close();
}
else{
document.getElementById("status").innerText=Math.round(part/whole*100) + "%";
document.getElementById("LB1").style.width=Math.round(part/whole*100);
}
}
window.returnValue = self;
</script>
</head>
<body style="background-color:black;color:white">
<span id="LB0" style="position:absolute;left:50%;top:50%;">
<span style="position:absolute;font-family:arial;font-size:10px;color:#FFFFFF;left:-50;top:-18">
<span id="message">Checking...</span><span id="status"></span>
</span>
<span style="position:absolute;left:-50;top:-5;font-size:1px;width:100;height:10px;background:#333">
<span id="LB1" style="position:absolute;left:0;top:0;font-size:1px;width:0;height:10px;background:#FFFFFF"></span>
</span>
</span>
</body>
</html>
In your HTA or HTML do this to start the progress bar:
var progress=window.showModelessDialog("progress.html",self,"dialogHeight: 200px; dialogWidth: 400px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
This will assign the progress bar to a variable and keep the window on top at all times. when the progress bar reaches 100% it will close itself
How to update the progress bar:
First you should determine the total length of the items you are going through, wether it be the length of an array, or total number of objects.
Inside your loop update the progress bar like this:
progress.progress(current index,Total Elements - 1); //0 based array
To update the message in the progress bar:
progress.getElementById("message").innerText="Checking hidden files"
Example to play with:
test.hta
<html>
<head>
<title>Progress bar test</title>
</head>
<body>
<button onclick="doIt()">GO!</button>
<script type="text/javascript">
function doIt(){
var progress=window.showModelessDialog("progress.html",self,"dialogHeight: 200px; dialogWidth: 400px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");
for(var i=0;i<4000;i++){
progress.progress(i,4000)
}
}
</script>
</body>
</html>
<message edited by TNO on Friday, May 22, 2009 4:05 AM>