Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21304
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Mel Smith" <med_cutout_syntel@aol.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Suspending the flow of JS/ES execution |
| Date | Thu, 12 Sep 2013 15:00:15 -0600 |
| Lines | 162 |
| Message-ID | <b9eob3Frcm0U1@mid.individual.net> (permalink) |
| References | <b9ekdcFqih1U1@mid.individual.net> <4fpYt.72772$wA2.68551@fx32.iad> |
| X-Trace | individual.net wqbOsT8zls3AKcaOAnkJagTPvg0siyPqO0HfUj24v/37hKop8k |
| Cancel-Lock | sha1:itSlRKqZ24uqbYnM0c+F4wqwUJA= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| X-Newsreader | Microsoft Outlook Express 6.00.2900.5931 |
| X-RFC2646 | Format=Flowed; Response |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2900.6157 |
| Xref | csiph.com comp.lang.javascript:21304 |
Show key headers only | View raw
Daniel said:
> Unless MyNewAlert goes out of its way to do something asynchronously,
> you've already got that.
>
> If that is the case, you'll need to rely on callbacks.
>
Hi Daniel:
Below is the body of my new alert function called Alert() -- note the
capitalized 'A' so I still have the regular alert() available.
Also, I've been experimenting with setTimeout() and setInterval(and gotr
deeper into trouble :(
Hope you can suggest some code that will stop further execution until
the new Alert() function is complete and the 'OK' button is clicked.
btw, I don't *think* I went out of my way to do something asynchronously
... ???
Thanks,
-Mel Smith
****** here's the code -- please don't throw up on it *******
var alertinit = false; // build new Alert on first call
var alertinps,nalertinps,alertdisables ;
function Alert(cmsg) {
var i,alertobj,capobj,msgobj,okobj ;
var inpobj ;
alertinps = document.getElementsByTagName("input") ;
nalertinps = alertinps.length ;
alertdisables = [] ;
for (i=0;i<nalertinps;i++) {
inpobj = alertinps[i] ;
if (inpobj.hidden) continue ;
if (inpobj.disabled) alertdisables.push(i.toString()) ;
if (inpobj.id && inpobj.id == "ialertokbutt") continue ;
inpobj.disabled = true ;
}
if (!alertinit) { // then create the alert box
var alertdiv = document.createElement("div") ;
alertdiv.id = "ialert" ;
alertdiv.style.display = "none" ;
alertdiv.innerHTML =
'<p id="ialertcaption"></p>' +
'<p id="ialertmsg"></p>' +
'<br />' +
'<div id="ialertok">' +
'<input type="button" id="ialertokbutt" onclick="AlertFin();" value="OK"
/> ' +
'</div>'
var containobj = getobj("container") ;
containobj.appendChild(alertdiv) ;
alertinit = true; // use it from now on
}
alertobj = getobj("ialert") ;
// now set the style for the main alert box
alertobj.style.position = "absolute" ;
alertobj.style.top = "30%" ;
alertobj.style.left = "25%" ;
alertobj.style.height = "40%" ;
alertobj.style.width = "50%" ;
alertobj.style.marginTop = "0px" ;
alertobj.style.marginBottom = "0px" ;
alertobj.style.padding = "0px" ;
alertobj.style.zIndex = "1000" ;
alertobj.style.overflow = "auto" ;
alertobj.style.textAlign = "center" ;
alertobj.style.color = "black" ;
alertobj.style.background = "lightgray" ;
alertobj.style.border = "2px solid black" ;
// now set styling for the alert caption
capobj = getobj("ialertcaption") ;
capobj.style.position = "absolute" ;
capobj.style.top = "0%" ;
capobj.style.height = "12%" ;
capobj.style.marginTop = "0px" ;
capobj.style.marginBottom = "0px" ;
capobj.style.padding = "0px" ;
capobj.style.left = "0%" ;
capobj.style.width = "100%" ;
capobj.style.textAlign = "center" ;
capobj.style.fontWeight = "bolder" ;
capobj.style.textDecoration = "underline" ;
capobj.style.color = "black" ;
capobj.style.background = "yellow" ;
capobj.innerHTML = " Please Read Message Below, then Click 'OK' "
;
// now prepare and display the message
msgobj = getobj("ialertmsg") ;
msgobj.style.position = "absolute" ;
msgobj.style.top = "20%" ;
msgobj.style.left = "0%" ;
msgobj.style.width = "100%" ;
msgobj.style.marginTop = "0px" ;
msgobj.style.marginBottom = "0px";
msgobj.style.padding = "0px";
msgobj.style.textAlign = "center" ;
// re-format with <br /> replacing '~' chars, etc
cmsg = cmsg.replace(/~/g,"<br />") ;
msgobj.innerHTML = cmsg ;
// now place the 'OK' button a bit up from the bottom of my standard Alert
Box
okobj = getobj("ialertok") ;
okobj.style.position = "absolute" ;
okobj.style.bottom = "5%" ;
okobj.style.left = "45%" ;
okobj.style.width = "10%" ;
okobj.style.marginTop = "0px" ;
okobj.style.marginBottom = "0px";
okobj.style.padding = "0px";
okobj.style.textAlign = "center" ;
alertobj.style.display="block" ;
getobj("ialertokbutt").focus() ;
// now somehow I have to stop execution flow past my alert box ???
}
function AlertFin() {
var i,j ;
var lexit ;
var nlendisables = alertdisables.length ;
var alertobj = getobj("ialert") ;
alertobj.style.display = "none" ;
for (i=0;i<nalertinps;i++) {
lexit = false ;
inpobj = alertinps[i] ;
if (nlendisables > 0 ) {
for (j=0;j<nlendisables;j++) {
if (alertdisables[j] === i.toString()) {
lexit = true ;
break ;
}
}
if (lexit) continue ;
}
inpobj.disabled = false ;
}
alertinps = null ;
nalertinps = 0 ;
alertdisables = null ;
return ;
}
****************************
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Suspending the flow of JS/ES execution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-09-12 13:53 -0600
Re: Suspending the flow of JS/ES execution Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-09-12 13:12 -0700
Re: Suspending the flow of JS/ES execution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-09-12 15:00 -0600
Re: Suspending the flow of JS/ES execution JJ <duh@nah.meh> - 2013-09-13 04:53 +0700
Re: Suspending the flow of JS/ES execution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-09-12 18:42 -0600
Re: Suspending the flow of JS/ES execution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-09-13 09:09 -0600
Re: Suspending the flow of JS/ES execution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-09-13 10:11 -0600
Re: Suspending the flow of JS/ES execution "Mel Smith" <med_cutout_syntel@aol.com> - 2013-09-13 13:07 -0600
csiph-web