Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13905 > unrolled thread
| Started by | Olve <Olve@nowhere.wd.invalid> |
|---|---|
| First post | 2012-05-14 23:38 +0200 |
| Last post | 2012-05-17 13:23 -0700 |
| Articles | 13 — 6 participants |
Back to article view | Back to comp.lang.javascript
A kind of flush ? Olve <Olve@nowhere.wd.invalid> - 2012-05-14 23:38 +0200
Re: A kind of flush ? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-14 23:21 +0000
Re: A kind of flush ? Olve <Olve@nowhere.wd.invalid> - 2012-05-15 10:44 +0200
Re: A kind of flush ? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-15 09:15 +0000
Re: A kind of flush ? Olve <Olve@nowhere.wd.invalid> - 2012-05-15 11:51 +0200
Re: A kind of flush ? Olve <Olve@nowhere.wd.invalid> - 2012-05-16 09:16 +0200
Re: A kind of flush ? Dr J R Stockton <reply1220@merlyn.demon.co.uk.not.invalid> - 2012-05-15 20:22 +0100
Re: A kind of flush ? Olve <Olve@nowhere.wd.invalid> - 2012-05-16 08:28 +0200
Re: A kind of flush ? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-16 15:00 +0000
Re: A kind of flush ? Swifty <steve.j.swift@gmail.com> - 2012-05-16 17:43 +0100
Re: A kind of flush ? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-17 18:47 +0000
Re: A kind of flush ? Scott Sauyet <scott.sauyet@gmail.com> - 2012-05-17 13:20 -0700
Re: A kind of flush ? Gene Wirchenko <genew@ocis.net> - 2012-05-17 13:23 -0700
| From | Olve <Olve@nowhere.wd.invalid> |
|---|---|
| Date | 2012-05-14 23:38 +0200 |
| Subject | A kind of flush ? |
| Message-ID | <4fb17b40$0$6460$426a74cc@news.free.fr> |
Dear all, I'm using javascript essentially for me or some well chosen users :) Sometimes the computations asked for are very lengthy. At every step (a step can take 1 or 2 minutes), a message is added to be displayed, but it get displayed only when the main function ends -- Can you please indicate me how this problem is usually handled? Many thanks in advance! Best, O.
[toc] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-05-14 23:21 +0000 |
| Message-ID | <XnsA054DD5EAA9Eeejj99@194.109.133.133> |
| In reply to | #13905 |
Olve wrote on 14 mei 2012 in comp.lang.javascript: > I'm using javascript essentially for me or some well chosen users :) > Sometimes the computations asked for are very lengthy. > At every step (a step can take 1 or 2 minutes), a message is added to be > displayed, but it get displayed only when the main function ends -- > > Can you please indicate me how this problem is usually handled? > Many thanks in advance! It is only a problem because you say so. Usually it is not a problem, so needs no handling at all.. I suppose you are speaking about clientside javascript script in a browser? If you want to display messages during computation, [and why would you, unless you want to display the way your computation goes], just cut the computation into parts, and restart it with a timeout of a few milisecs, so that the dom has time to write to the window. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Olve <Olve@nowhere.wd.invalid> |
|---|---|
| Date | 2012-05-15 10:44 +0200 |
| Message-ID | <4fb21764$0$6832$426a34cc@news.free.fr> |
| In reply to | #13977 |
Then it means I haven't understood something.
Here is a code below.
The first one is with a loop. If you click on Go, you will get the
proper message but after the script is exited !
The second one has a setTimeout and you will see that this behaves like
a closure : the final value is 3 3 3 !!!
Many thanks for comments!
A.O.
-------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script language="javascript">
function pausecomp (ms) {
ms += new Date().getTime();
while (new Date() < ms){}}
function GoToWork(){
pausecomp(1000);
document.getElementById("MailBox").innerHTML = "First messg";
for(var x = 0; x < 3; x++){
pausecomp(1000);
document.getElementById("MailBox").innerHTML += " -- "+x;}}
function GoToWorkAgain(){
pausecomp(1000);
document.getElementById("MailBox2").innerHTML = "First messg";
for(var x = 0; x < 3; x++){
setTimeout(function(){
document.getElementById("MailBox2").innerHTML += " "+x;},
2)}}
</script>
</head>
<body >
<form><table>
<tr>
<td><input type="button" onClick="GoToWork()" value="Go"></td>
<td id="MailBox"></td>
</tr>
<tr>
<td><input type="button" onClick="GoToWorkAgain()" value="With
setTimeout"></td>
<td id="MailBox2"></td>
</tr>
</table></form>
</body>
</html>
--------------------------------------------------------------------------
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-05-15 09:15 +0000 |
| Message-ID | <XnsA0547284F6B4eejj99@194.109.133.133> |
| In reply to | #13982 |
Olve wrote on 15 mei 2012 in comp.lang.javascript:
> Then it means I haven't understood something.
Indeed, this is not email.
This is is usenet [one-to-many communication],
so quote the part(s) that you are replying on,
> Here is a code below.
> The first one is with a loop. If you click on Go, you will get the
> proper message but after the script is exited !
It is not the whole script that should be exited, but the "sub-"function,
see below and get excited.
[..]
> <script language="javascript">
is last century's code, use:
<script type='text/javascript'>
> while (new Date() < ms){}}
Wow! This is not pausing, you keep the microprocessor running at full
speed, meaning full speed allowed to this javascript process. You will have
to set a interrupt and leave the process. That way the dom-process will
have time to do things, and you are more polite to other processes on your
pc, like the other running programmes, system clock, sound and light and
the interrupt mechanism.
That means you will have to rewrite your code into a whole other setup,
where a function the does a small part of your 'computation' and then ENDS
after calling setTimeOut();.
After say 20ms the timeout fires [restarts the process] the next instance
of your function. Between the end and the restart the dom gets time to
paint the new canvas, as I wrote earlier.
This goes on till the final result is reached, or a fixed number of
iterations is reached after which the function does not
reiterate with the next setTimout call but goes to somehere else.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Olve <Olve@nowhere.wd.invalid> |
|---|---|
| Date | 2012-05-15 11:51 +0200 |
| Message-ID | <4fb22724$0$712$426a74cc@news.free.fr> |
| In reply to | #13983 |
[...] > Wow! This is not pausing, you keep the microprocessor running at full > speed, meaning full speed allowed to this javascript process. This was to imitate my process, which will run at full speed and be very hungry, in time and memory. [...] > That means you will have to rewrite your code into a whole other setup, > where a function the does a small part of your 'computation' and then ENDS > after calling setTimeOut();. Ok, thanks. O.
[toc] | [prev] | [next] | [standalone]
| From | Olve <Olve@nowhere.wd.invalid> |
|---|---|
| Date | 2012-05-16 09:16 +0200 |
| Message-ID | <4fb35435$0$1696$426a74cc@news.free.fr> |
| In reply to | #13983 |
That works perfectly, thanks! A.O.
For future reference:
----------------------
Instead of:
while(cond(param)){
things-to-do(param);
write-things-on-the-screen(param);
param = modify(param)
};
I wrote:
run(param);
where the function run is defined by:
function run(param){
if(cond(param)){
things-to-do(param);
write-things-on-the-screen(param);
param = modify(param);
setTimeout(function(){run(param);},10);
} else {return ;}}
------------------------------------------
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1220@merlyn.demon.co.uk.not.invalid> |
|---|---|
| Date | 2012-05-15 20:22 +0100 |
| Message-ID | <3JPyL9G2zqsPFwgA@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #13905 |
In comp.lang.javascript message <4fb17b40$0$6460$426a74cc@news.free.fr>, Mon, 14 May 2012 23:38:08, Olve <Olve@nowhere.wd.invalid> posted: > I'm using javascript essentially for me or some well chosen users :) >Sometimes the computations asked for are very lengthy. >At every step (a step can take 1 or 2 minutes), a message is added to >be displayed, but it get displayed only when the main function ends -- Your easiest move is to select a browser which updates the display while it is calculating. Opera does that (Opera 11.64, Win XP sp3); not MS IE, Firefox, Safari, Chrome. One can write to window.status, which sometimes updates while calculating. In MS IE 8, Opera, Safari, yes, bottom of screen. Firefox, Chrome, no. In each case that is probably with default settings, and there may be relevant options. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
[toc] | [prev] | [next] | [standalone]
| From | Olve <Olve@nowhere.wd.invalid> |
|---|---|
| Date | 2012-05-16 08:28 +0200 |
| Message-ID | <4fb348f0$0$1719$426a74cc@news.free.fr> |
| In reply to | #13999 |
Thanks for this input -- I'm intending this code mostly for firefox and chrome -- Best, A.O.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-05-16 15:00 +0000 |
| Message-ID | <XnsA055AD0B3EC89eejj99@194.109.133.133> |
| In reply to | #14008 |
Olve wrote on 16 mei 2012 in comp.lang.javascript: > Thanks for this input And again, you think this is email. On Usenet we [most of us] are not aware what you are referring to, if you don't quote. Please follow Usenet Netiquette and read the NG FAQ. > -- I'm intending this code mostly for firefox and chrome -- "Mostly"? Even if it just a good way of exercising your programming skills, one should aim to include as much modern browser compatibility as feasable. "This motorway is mainly intended for Toyota, Ford and Maserati", indeed. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Swifty <steve.j.swift@gmail.com> |
|---|---|
| Date | 2012-05-16 17:43 +0100 |
| Message-ID | <nml7r7l02bkhc573ui5463chpf7j2khnjt@4ax.com> |
| In reply to | #14015 |
On 16 May 2012 15:00:39 GMT, "Evertjan." <exjxw.hannivoort@interxnl.net> wrote: >Even if it just a good way of exercising your programming skills, one >should aim to include as much modern browser compatibility as feasable. Whilst laudable (and indeed, I strive for this in my own feeble way), some of us work in closed environments where only certain browsers are approved. Sometimes the list is just one (Ministry of Defence contracts spring to mind). Personally, I'm obliged to support only IE8 and above or FF10 ESR (at the moment, it's a moving target). So, any extra effort to support other browsers, or other releases comes out of our own pockets. Indeed, it's worse than that; I'm in competition with other developers in our organisation, and if I'm less productive than them, then I get shown the door. How much for Opera/Safari/Chome support now? When insisting that we all tolerate the differences, we have to accept that one possible difference is someone who cannot tolerate differences, for one reason or another. :-) -- Steve Swift http://www.swiftys.org.uk/swifty.html http://www.ringers.org.uk
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-05-17 18:47 +0000 |
| Message-ID | <XnsA056D37177EBFeejj99@194.109.133.133> |
| In reply to | #14017 |
Swifty wrote on 16 mei 2012 in comp.lang.javascript: > On 16 May 2012 15:00:39 GMT, "Evertjan." > <exjxw.hannivoort@interxnl.net> wrote: > >>Even if it just a good way of exercising your programming skills, one >>should aim to include as much modern browser compatibility as feasable. > > Whilst laudable (and indeed, I strive for this in my own feeble way), > some of us work in closed environments where only certain browsers are > approved. Sometimes the list is just one (Ministry of Defence > contracts spring to mind). > > Personally, I'm obliged to support only IE8 and above or FF10 ESR (at > the moment, it's a moving target). > > So, any extra effort to support other browsers, or other releases > comes out of our own pockets. Indeed, it's worse than that; I'm in > competition with other developers in our organisation, and if I'm less > productive than them, then I get shown the door. > > How much for Opera/Safari/Chome support now? > > When insisting that we all tolerate the differences, we have to accept > that one possible difference is someone who cannot tolerate > differences, for one reason or another. :-) I understand you, though my opinion is that a professional should not want to give in to such restrictions, also in fear of losing his or her own general expertise, which will be even more essential when looking for another job. Furthermore I would argue that such restrictions should be declared off- topic in this NG [which they are not at present] because of the bad effect it will have on our professional newbees. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2012-05-17 13:20 -0700 |
| Message-ID | <13eec7eb-5de4-481e-9c7d-972596637afa@f30g2000vbz.googlegroups.com> |
| In reply to | #14030 |
Evertjan wrote: > Furthermore I would argue that such restrictions [supporting only some small > subset of browsers] should be declared off-topic in this NG [which they are > not at present] because of the bad effect it will have on our professional > newbees. I'm not sure how we could do that without allowing for those who would like to say "I don't care about supporting Lynx / NN4 /IE3". I don't think these should be off-topic. But they should be clearly marked as such. Perhaps something like "IE7+ only" somewhere in the subject. -- Scott
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-05-17 13:23 -0700 |
| Message-ID | <f5nar75aimcdc8iqn3mmo766il3c0sg79u@4ax.com> |
| In reply to | #14017 |
On Wed, 16 May 2012 17:43:20 +0100, Swifty <steve.j.swift@gmail.com>
wrote:
>On 16 May 2012 15:00:39 GMT, "Evertjan."
><exjxw.hannivoort@interxnl.net> wrote:
>
>>Even if it just a good way of exercising your programming skills, one
>>should aim to include as much modern browser compatibility as feasable.
>
>Whilst laudable (and indeed, I strive for this in my own feeble way),
>some of us work in closed environments where only certain browsers are
>approved. Sometimes the list is just one (Ministry of Defence
>contracts spring to mind).
Should another be added to the list and your code breaks, you
will not look so good.
>Personally, I'm obliged to support only IE8 and above or FF10 ESR (at
>the moment, it's a moving target).
>
>So, any extra effort to support other browsers, or other releases
>comes out of our own pockets. Indeed, it's worse than that; I'm in
>competition with other developers in our organisation, and if I'm less
>productive than them, then I get shown the door.
It might not be more than minor. If you do not concern yourself
with more than the minimum, you might also be shown the door. It is
also possible that once you do work out the more general approach, it
is easier to use.
>How much for Opera/Safari/Chome support now?
>
>When insisting that we all tolerate the differences, we have to accept
>that one possible difference is someone who cannot tolerate
>differences, for one reason or another. :-)
Ah, yes, bigots. <BEG>
I read Evertjan's reply before replying. I agree with his post.
That stated, I currently have a situation where my code works in
IE 9 (the approved browser), but due to some of the stuff that I am
doing, it does not work quite right in Firefox. My priority is to get
to code that the end users can run, but the Firefox deficiency is
fairly high on the list to deal with. When I know more JavaScript, I
expect it will be easier to deal with. There is no way that I want my
code to not work with a common browser if it is all that easy to have
it work.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web