dealy663@hotmail.com (Derek) wrote in message news:<60fbcb9d.0308191315.6f33baa5@posting.google. com>...
[color=blue]
> Finally what is the best way to give the users visible feedback that
> the filtering function is working and that things aren't locked up?
> The cursor doesn't change to the hourglass when the function is
> running. And when I tried to output to another frame some progress
> messages none of that data appeared in the frame until after the
> filtering function had returned.[/color]
You could (1) split the main job in little jobs (easy if you have some
kind of a loop in your main job) and (2) chain the job parts calls
with timeouts, in order for the UI to get updated and the browser not
to get terrified at how fast your script is eating memory :-) To put
it another way, you'd give the browser some time to breathe while
working. The following quick demo should demonstrate the technique,
you'll have to make the split and find a more elegant way to inform
the user, though.
<script type="text/javascript">
//emulate the job part
function JobPart(){ /1(.+)+1/.test("011000"); }
// emulate the job chain
var A_Jobs=[]
for(var ii=0; ii<100; ii++)
A_Jobs[ii]=JobPart;
// job controller
var Job = function() {
var ii=0, d=document;
var UserInform = {
start : function() { c("wait"); window.status="0%"; },
update : function(state) { window.status=state+"%"; },
stop : function() { c("default"); window.status=""; }
};
var c=function(a){document.body.style.cursor=a;};
return function (){
UserInform.start();
A_Jobs[ii++]();
UserInform.update(Math.floor(ii*100/A_Jobs.length));
if (ii<A_Jobs.length) setTimeout(arguments.callee, 1);
else {
ii=0;
UserInform.stop();
}
}
}();
</script>
<input type="button" value="Lauch job" onclick="Job()">
HTH
Yep.