Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29896 > unrolled thread

Wait on keyboard

Started byjonas.thornvall@gmail.com
First post2016-03-11 02:30 -0800
Last post2016-03-14 18:58 +0800
Articles 20 on this page of 63 — 10 participants

Back to article view | Back to comp.lang.javascript


Contents

  Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 02:30 -0800
    Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-11 10:37 +0000
    Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 02:50 -0800
      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:13 -0800
        Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:23 -0800
          Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:32 -0800
            Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:39 -0800
              Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 04:41 -0800
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 05:00 -0800
                  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 05:43 -0800
        Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-11 12:13 +0000
    Re: Wait on keyboard "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-11 21:52 +0800
      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 07:29 -0800
    Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-11 17:00 +0100
      Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-11 17:11 +0100
        Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 08:32 -0800
          Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-11 20:20 +0100
        Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 08:55 -0800
          Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-11 16:30 -0300
            Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 11:46 -0800
              Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:22 -0800
                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-11 17:25 -0300
                  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:32 -0800
                    Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-11 17:42 -0300
                      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:52 -0800
                    Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:47 -0800
                    Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:39 -0800
                Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:37 -0800
                Re: Wait on keyboard John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-12 13:16 +0000
                  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 05:57 -0800
                    Re: Wait on keyboard John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-13 10:31 +0000
                      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 05:55 -0700
                        Re: Wait on keyboard "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-13 17:19 +0100
                        Re: Wait on keyboard Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-13 13:01 -0700
                          Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 15:19 -0700
                            Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-13 20:08 -0300
                              Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 21:45 -0700
                                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-14 01:50 -0300
                                  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 22:39 -0700
                                    Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 22:46 -0700
                                    Re: Wait on keyboard Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-14 11:54 -0700
                                Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-14 08:31 +0000
                                Re: Wait on keyboard John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-14 10:43 +0000
                  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 06:04 -0800
                    Re: Wait on keyboard "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-12 15:22 +0100
                      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 07:46 -0800
                        Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-12 15:52 +0000
                        Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 09:25 -0800
                          Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-12 20:16 -0300
                            Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 15:57 -0800
                              Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-12 21:07 -0300
                              Re: Wait on keyboard Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-12 21:27 -0800
                                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 03:08 -0700
                        Re: Wait on keyboard "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-12 23:30 +0100
                  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 06:15 -0800
              Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:33 -0800
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 03:01 -0800
      Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:30 -0800
      Re: Wait on keyboard Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-12 04:44 +0100
        Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-12 11:21 +0100
          Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-12 11:27 +0100
          Re: Wait on keyboard Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-12 14:44 +0100
      Re: Wait on keyboard "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-14 18:58 +0800

Page 1 of 4  [1] 2 3 4  Next page →


#29896 — Wait on keyboard

Fromjonas.thornvall@gmail.com
Date2016-03-11 02:30 -0800
SubjectWait on keyboard
Message-ID<6ef267d6-7655-4699-9363-d6e0f613f899@googlegroups.com>
I need to debug, and i real do not like the gist of firefox nor chrome debug.

And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?

Is there something like.  wait until pressed key equal space.

Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.

So wait on keyboard?

[toc] | [next] | [standalone]


#29897

FromTim Streater <timstreater@greenbee.net>
Date2016-03-11 10:37 +0000
Message-ID<110320161037146992%timstreater@greenbee.net>
In reply to#29896
In article <6ef267d6-7655-4699-9363-d6e0f613f899@googlegroups.com>,
<jonas.thornvall@gmail.com> wrote:

>I need to debug, and i real do not like the gist of firefox nor chrome debug.
>
>And i kind of like do my own debug printouts, how can i program javascript to
>wait for keyboard input?
>
>Is there something like.  wait until pressed key equal space.
>
>Is there a way to achieve this because then i will be able to do my own
>printouts to textareas and i can also see where the loop starts without to get
>indefinitly stuck or thrown out.
>
>So wait on keyboard?

That's not how it works. Javascript is event driven, so will respond
via an event handler when you press a key.

You can generate debug output visible in the debug consoles of
browsers, using statements like:

  console.log ("x = " + x);

I've always found these quite useful.

-- 
Lady Astor: "If you were my husband I'd give you poison." Churchill: "If
you were my wife, I'd drink it."

[toc] | [prev] | [next] | [standalone]


#29898

Fromjonas.thornvall@gmail.com
Date2016-03-11 02:50 -0800
Message-ID<f7aaada6-5407-4764-83e9-0ef13953090a@googlegroups.com>
In reply to#29896
Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> I need to debug, and i real do not like the gist of firefox nor chrome debug.
> 
> And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> 
> Is there something like.  wait until pressed key equal space.
> 
> Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> 
> So wait on keyboard?

To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  

If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.

Is there a reason?

[toc] | [prev] | [next] | [standalone]


#29899

Fromjonas.thornvall@gmail.com
Date2016-03-11 03:13 -0800
Message-ID<41dca990-88fe-4829-8fbb-fd8811727776@googlegroups.com>
In reply to#29898
Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > 
> > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > 
> > Is there something like.  wait until pressed key equal space.
> > 
> > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > 
> > So wait on keyboard?
> 
> To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> 
> If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> 
> Is there a reason?

Here is the sample code someone suggested on net, and it makes you wonder.
Do they require the input to come from a specific field in a form????

Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?

Should not the keyboard listener be implicit in a programming language?
a=getkey();
if (a=="32");
document.write("You pressed return");

How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.

var waitingForEnter = false;

function appear()
{
     document.getElementById("firstt").style.visibility="visible";
     waitingForEnter = true;
}

function keydownHandler(e) {

    if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
        document.getElementById("startrouter").style.visibility="visible";
        waitingForEnter = false; // reset variable
    }
}

// register your handler method for the keydown event
if (document.addEventListener) {
    document.addEventListener('keydown', keydownHandler, false);
}
else if (document.attachEvent) {
    document.attachEvent('onkeydown', keydownHandler);
}

[toc] | [prev] | [next] | [standalone]


#29900

Fromjonas.thornvall@gmail.com
Date2016-03-11 03:23 -0800
Message-ID<dc932bfa-4821-46bb-b28d-cb36f77e540e@googlegroups.com>
In reply to#29899
Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > 
> > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > 
> > > Is there something like.  wait until pressed key equal space.
> > > 
> > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > 
> > > So wait on keyboard?
> > 
> > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> > 
> > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > 
> > Is there a reason?
> 
> Here is the sample code someone suggested on net, and it makes you wonder.
> Do they require the input to come from a specific field in a form????
> 
> Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> 
> Should not the keyboard listener be implicit in a programming language?
> a=getkey();
> if (a=="32");
> document.write("You pressed return");
> 
> How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> 
> var waitingForEnter = false;
> 
> function appear()
> {
>      document.getElementById("firstt").style.visibility="visible";
>      waitingForEnter = true;
> }
> 
> function keydownHandler(e) {
> 
>     if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
>         document.getElementById("startrouter").style.visibility="visible";
>         waitingForEnter = false; // reset variable
>     }
> }
> 
> // register your handler method for the keydown event
> if (document.addEventListener) {
>     document.addEventListener('keydown', keydownHandler, false);
> }
> else if (document.attachEvent) {
>     document.attachEvent('onkeydown', keydownHandler);
> }

Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?

So my question why do not a simple boolean suffice to but a listener on and off?

Mouse events

onclick 	
oncontextmenu 	
ondblclick 	 	
onmousedown 	
onmouseenter 	 	
onmouseleave 	
onmousemove 		
onmouseover 	
onmouseout 	
onmouseup 	

Keyboard Events

onkeydown 	
onkeypress 	
onkeyup

[toc] | [prev] | [next] | [standalone]


#29901

Fromjonas.thornvall@gmail.com
Date2016-03-11 03:32 -0800
Message-ID<8be2a399-5abc-41f2-aee7-4dbfc80c1ae6@googlegroups.com>
In reply to#29900
Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > 
> > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > 
> > > > Is there something like.  wait until pressed key equal space.
> > > > 
> > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > 
> > > > So wait on keyboard?
> > > 
> > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> > > 
> > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > 
> > > Is there a reason?
> > 
> > Here is the sample code someone suggested on net, and it makes you wonder.
> > Do they require the input to come from a specific field in a form????
> > 
> > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > 
> > Should not the keyboard listener be implicit in a programming language?
> > a=getkey();
> > if (a=="32");
> > document.write("You pressed return");
> > 
> > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > 
> > var waitingForEnter = false;
> > 
> > function appear()
> > {
> >      document.getElementById("firstt").style.visibility="visible";
> >      waitingForEnter = true;
> > }
> > 
> > function keydownHandler(e) {
> > 
> >     if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
> >         document.getElementById("startrouter").style.visibility="visible";
> >         waitingForEnter = false; // reset variable
> >     }
> > }
> > 
> > // register your handler method for the keydown event
> > if (document.addEventListener) {
> >     document.addEventListener('keydown', keydownHandler, false);
> > }
> > else if (document.attachEvent) {
> >     document.attachEvent('onkeydown', keydownHandler);
> > }
> 
> Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> 
> So my question why do not a simple boolean suffice to but a listener on and off?
> 
> Mouse events
> 
> onclick 	
> oncontextmenu 	
> ondblclick 	 	
> onmousedown 	
> onmouseenter 	 	
> onmouseleave 	
> onmousemove 		
> onmouseover 	
> onmouseout 	
> onmouseup 	
> 
> Keyboard Events
> 
> onkeydown 	
> onkeypress 	
> onkeyup

It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".

But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?

Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?

[toc] | [prev] | [next] | [standalone]


#29902

Fromjonas.thornvall@gmail.com
Date2016-03-11 03:39 -0800
Message-ID<704d3399-1aed-4c47-8ded-2da42e6d1760@googlegroups.com>
In reply to#29901
Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > 
> > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > 
> > > > > Is there something like.  wait until pressed key equal space.
> > > > > 
> > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > 
> > > > > So wait on keyboard?
> > > > 
> > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> > > > 
> > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > 
> > > > Is there a reason?
> > > 
> > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > Do they require the input to come from a specific field in a form????
> > > 
> > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > 
> > > Should not the keyboard listener be implicit in a programming language?
> > > a=getkey();
> > > if (a=="32");
> > > document.write("You pressed return");
> > > 
> > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > 
> > > var waitingForEnter = false;
> > > 
> > > function appear()
> > > {
> > >      document.getElementById("firstt").style.visibility="visible";
> > >      waitingForEnter = true;
> > > }
> > > 
> > > function keydownHandler(e) {
> > > 
> > >     if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
> > >         document.getElementById("startrouter").style.visibility="visible";
> > >         waitingForEnter = false; // reset variable
> > >     }
> > > }
> > > 
> > > // register your handler method for the keydown event
> > > if (document.addEventListener) {
> > >     document.addEventListener('keydown', keydownHandler, false);
> > > }
> > > else if (document.attachEvent) {
> > >     document.attachEvent('onkeydown', keydownHandler);
> > > }
> > 
> > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > 
> > So my question why do not a simple boolean suffice to but a listener on and off?
> > 
> > Mouse events
> > 
> > onclick 	
> > oncontextmenu 	
> > ondblclick 	 	
> > onmousedown 	
> > onmouseenter 	 	
> > onmouseleave 	
> > onmousemove 		
> > onmouseover 	
> > onmouseout 	
> > onmouseup 	
> > 
> > Keyboard Events
> > 
> > onkeydown 	
> > onkeypress 	
> > onkeyup
> 
> It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> 
> But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> 
> Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?

And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.

Especially it you can come up with a solution using less than 10 lines of code.

[toc] | [prev] | [next] | [standalone]


#29904

Fromjonas.thornvall@gmail.com
Date2016-03-11 04:41 -0800
Message-ID<e777e448-38a2-4a6a-948b-ebaf9517f8f2@googlegroups.com>
In reply to#29902
Den fredag 11 mars 2016 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > > 
> > > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > > 
> > > > > > Is there something like.  wait until pressed key equal space.
> > > > > > 
> > > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > > 
> > > > > > So wait on keyboard?
> > > > > 
> > > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> > > > > 
> > > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > > 
> > > > > Is there a reason?
> > > > 
> > > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > > Do they require the input to come from a specific field in a form????
> > > > 
> > > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > > 
> > > > Should not the keyboard listener be implicit in a programming language?
> > > > a=getkey();
> > > > if (a=="32");
> > > > document.write("You pressed return");
> > > > 
> > > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > > 
> > > > var waitingForEnter = false;
> > > > 
> > > > function appear()
> > > > {
> > > >      document.getElementById("firstt").style.visibility="visible";
> > > >      waitingForEnter = true;
> > > > }
> > > > 
> > > > function keydownHandler(e) {
> > > > 
> > > >     if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
> > > >         document.getElementById("startrouter").style.visibility="visible";
> > > >         waitingForEnter = false; // reset variable
> > > >     }
> > > > }
> > > > 
> > > > // register your handler method for the keydown event
> > > > if (document.addEventListener) {
> > > >     document.addEventListener('keydown', keydownHandler, false);
> > > > }
> > > > else if (document.attachEvent) {
> > > >     document.attachEvent('onkeydown', keydownHandler);
> > > > }
> > > 
> > > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > > 
> > > So my question why do not a simple boolean suffice to but a listener on and off?
> > > 
> > > Mouse events
> > > 
> > > onclick 	
> > > oncontextmenu 	
> > > ondblclick 	 	
> > > onmousedown 	
> > > onmouseenter 	 	
> > > onmouseleave 	
> > > onmousemove 		
> > > onmouseover 	
> > > onmouseout 	
> > > onmouseup 	
> > > 
> > > Keyboard Events
> > > 
> > > onkeydown 	
> > > onkeypress 	
> > > onkeyup
> > 
> > It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> > 
> > But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> > 
> > Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?
> 
> And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.
> 
> Especially it you can come up with a solution using less than 10 lines of code.

Pseudcode.

wait until key pressed.

If you do not like wait(3000); 
You could do something in the line already in language.
setKeyInput(myFunction, keyPress="32")

But i prefer wait until(keyPress=="32") anyday of the year.
And keyPress is a listener that can be turned on and off with boolean true/false.

So during execution you can chose function to be called from keyboard.
if (keyPress=="32") exit();

It so more clear than the current convolution of action. And it would enable you to steer program from keyboard. It is probably possible even now, but it is so fucking convoluted you can not see it.

I would guess that return somehow reserved for submit, but i could have use for the other 103 keyes and their combinations.

Isn't it evolution a bit fucking weird when something that required one line of code suddenly need a library?

https://dmauro.github.io/Keypress/

[toc] | [prev] | [next] | [standalone]


#29905

Fromjonas.thornvall@gmail.com
Date2016-03-11 05:00 -0800
Message-ID<3e752d8b-8777-4d46-9076-597a3a41a6c8@googlegroups.com>
In reply to#29904
Den fredag 11 mars 2016 kl. 13:41:29 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > > > 
> > > > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > > > 
> > > > > > > Is there something like.  wait until pressed key equal space.
> > > > > > > 
> > > > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > > > 
> > > > > > > So wait on keyboard?
> > > > > > 
> > > > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> > > > > > 
> > > > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > > > 
> > > > > > Is there a reason?
> > > > > 
> > > > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > > > Do they require the input to come from a specific field in a form????
> > > > > 
> > > > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > > > 
> > > > > Should not the keyboard listener be implicit in a programming language?
> > > > > a=getkey();
> > > > > if (a=="32");
> > > > > document.write("You pressed return");
> > > > > 
> > > > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > > > 
> > > > > var waitingForEnter = false;
> > > > > 
> > > > > function appear()
> > > > > {
> > > > >      document.getElementById("firstt").style.visibility="visible";
> > > > >      waitingForEnter = true;
> > > > > }
> > > > > 
> > > > > function keydownHandler(e) {
> > > > > 
> > > > >     if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
> > > > >         document.getElementById("startrouter").style.visibility="visible";
> > > > >         waitingForEnter = false; // reset variable
> > > > >     }
> > > > > }
> > > > > 
> > > > > // register your handler method for the keydown event
> > > > > if (document.addEventListener) {
> > > > >     document.addEventListener('keydown', keydownHandler, false);
> > > > > }
> > > > > else if (document.attachEvent) {
> > > > >     document.attachEvent('onkeydown', keydownHandler);
> > > > > }
> > > > 
> > > > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > > > 
> > > > So my question why do not a simple boolean suffice to but a listener on and off?
> > > > 
> > > > Mouse events
> > > > 
> > > > onclick 	
> > > > oncontextmenu 	
> > > > ondblclick 	 	
> > > > onmousedown 	
> > > > onmouseenter 	 	
> > > > onmouseleave 	
> > > > onmousemove 		
> > > > onmouseover 	
> > > > onmouseout 	
> > > > onmouseup 	
> > > > 
> > > > Keyboard Events
> > > > 
> > > > onkeydown 	
> > > > onkeypress 	
> > > > onkeyup
> > > 
> > > It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> > > 
> > > But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> > > 
> > > Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?
> > 
> > And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.
> > 
> > Especially it you can come up with a solution using less than 10 lines of code.
> 
> Pseudcode.
> 
> wait until key pressed.
> 
> If you do not like wait(3000); 
> You could do something in the line already in language.
> setKeyInput(myFunction, keyPress="32")
> 
> But i prefer wait until(keyPress=="32") anyday of the year.
> And keyPress is a listener that can be turned on and off with boolean true/false.
> 
> So during execution you can chose function to be called from keyboard.
> if (keyPress=="32") exit();
> 
> It so more clear than the current convolution of action. And it would enable you to steer program from keyboard. It is probably possible even now, but it is so fucking convoluted you can not see it.
> 
> I would guess that return somehow reserved for submit, but i could have use for the other 103 keyes and their combinations.
> 
> Isn't it evolution a bit fucking weird when something that required one line of code suddenly need a library?
> 
> https://dmauro.github.io/Keypress/

Oh is see i need to learn an API so i can see what fucking key i pressed, if it wasn't a sad glimpse of a future where program language designers start to show sign of retardness it would be hilarious.

Really nobody think about programmers as users using an interface anymore?
What the fuck went wrong?

[toc] | [prev] | [next] | [standalone]


#29906

Fromjonas.thornvall@gmail.com
Date2016-03-11 05:43 -0800
Message-ID<acd66b43-0745-4aad-a3d4-bd76dc2a0799@googlegroups.com>
In reply to#29905
Den fredag 11 mars 2016 kl. 14:01:05 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 11 mars 2016 kl. 13:41:29 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 11 mars 2016 kl. 12:39:36 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 11 mars 2016 kl. 12:32:28 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 11 mars 2016 kl. 12:23:41 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 11 mars 2016 kl. 12:13:29 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > Den fredag 11 mars 2016 kl. 11:51:06 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > Den fredag 11 mars 2016 kl. 11:30:55 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > > > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > > > > > > > 
> > > > > > > > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> > > > > > > > 
> > > > > > > > Is there something like.  wait until pressed key equal space.
> > > > > > > > 
> > > > > > > > Is there a way to achieve this because then i will be able to do my own printouts to textareas and i can also see where the loop starts without to get indefinitly stuck or thrown out.
> > > > > > > > 
> > > > > > > > So wait on keyboard?
> > > > > > > 
> > > > > > > To be honest i find it weird that you have to add a listener and on key handlers it is pretty much 20 linke of code that have to be written.  
> > > > > > > 
> > > > > > > If i remember correctly it could be ahcieved with a single line in basic using either input or something like getkey.
> > > > > > > 
> > > > > > > Is there a reason?
> > > > > > 
> > > > > > Here is the sample code someone suggested on net, and it makes you wonder.
> > > > > > Do they require the input to come from a specific field in a form????
> > > > > > 
> > > > > > Isn't there listen for keyboard, what is firstt, how can a programming language be so convoluted that you can not listen for a simple keyboard press without 20 lines of code?
> > > > > > 
> > > > > > Should not the keyboard listener be implicit in a programming language?
> > > > > > a=getkey();
> > > > > > if (a=="32");
> > > > > > document.write("You pressed return");
> > > > > > 
> > > > > > How can this end up with constructing code like below that does not even work for the purpose, one can really wonder why javascript bothered implement write but not getkey.
> > > > > > 
> > > > > > var waitingForEnter = false;
> > > > > > 
> > > > > > function appear()
> > > > > > {
> > > > > >      document.getElementById("firstt").style.visibility="visible";
> > > > > >      waitingForEnter = true;
> > > > > > }
> > > > > > 
> > > > > > function keydownHandler(e) {
> > > > > > 
> > > > > >     if (e.keyCode == 13 && waitingForEnter) {  // 13 is the enter key
> > > > > >         document.getElementById("startrouter").style.visibility="visible";
> > > > > >         waitingForEnter = false; // reset variable
> > > > > >     }
> > > > > > }
> > > > > > 
> > > > > > // register your handler method for the keydown event
> > > > > > if (document.addEventListener) {
> > > > > >     document.addEventListener('keydown', keydownHandler, false);
> > > > > > }
> > > > > > else if (document.attachEvent) {
> > > > > >     document.attachEvent('onkeydown', keydownHandler);
> > > > > > }
> > > > > 
> > > > > Of course one really could ask the same for all mouse and listeners. What is the actual reason for not use simple booleans to toggle the listener. I mean they are there afterall implicit in the language? Sometimes i just do not get why approaches get so convoluted, so there must be alot more to these things?
> > > > > 
> > > > > So my question why do not a simple boolean suffice to but a listener on and off?
> > > > > 
> > > > > Mouse events
> > > > > 
> > > > > onclick 	
> > > > > oncontextmenu 	
> > > > > ondblclick 	 	
> > > > > onmousedown 	
> > > > > onmouseenter 	 	
> > > > > onmouseleave 	
> > > > > onmousemove 		
> > > > > onmouseover 	
> > > > > onmouseout 	
> > > > > onmouseup 	
> > > > > 
> > > > > Keyboard Events
> > > > > 
> > > > > onkeydown 	
> > > > > onkeypress 	
> > > > > onkeyup
> > > > 
> > > > It seem to me that javascript gone in the correct direction with strings and array handling. You can do things that would require alot of effort in basic and turbo pascal "well in most other programming languages".
> > > > 
> > > > But other aspects of the language seem to gone in the other direction and the listeners ***seem?*** to suffer from proverbial diarrhea really digging into anally exhausting linguistics with apparent use and usability of zero?
> > > > 
> > > > Is there different people responsible for developing these two parts of the language? It piss me off to be Frank how one can convolute straight forward things into some mystic listener religion?
> > > 
> > > And if someone can show me howto listen for a keyboard press generally, not using a specific input, checkbox, textarea select "id" or "name" i would appreciate it. Just a simple keyboard listener.
> > > 
> > > Especially it you can come up with a solution using less than 10 lines of code.
> > 
> > Pseudcode.
> > 
> > wait until key pressed.
> > 
> > If you do not like wait(3000); 
> > You could do something in the line already in language.
> > setKeyInput(myFunction, keyPress="32")
> > 
> > But i prefer wait until(keyPress=="32") anyday of the year.
> > And keyPress is a listener that can be turned on and off with boolean true/false.
> > 
> > So during execution you can chose function to be called from keyboard.
> > if (keyPress=="32") exit();
> > 
> > It so more clear than the current convolution of action. And it would enable you to steer program from keyboard. It is probably possible even now, but it is so fucking convoluted you can not see it.
> > 
> > I would guess that return somehow reserved for submit, but i could have use for the other 103 keyes and their combinations.
> > 
> > Isn't it evolution a bit fucking weird when something that required one line of code suddenly need a library?
> > 
> > https://dmauro.github.io/Keypress/
> 
> Oh is see i need to learn an API so i can see what fucking key i pressed, if it wasn't a sad glimpse of a future where program language designers start to show sign of retardness it would be hilarious.
> 
> Really nobody think about programmers as users using an interface anymore?
> What the fuck went wrong?

What i try to say, i think there may be an anal beadhead responsible for implementing the javascript liteners. It is not that i do not recognize the requirment to listen to interactive elements by id. It is the way it is implemented that is retarded and then i am prety kind to the one who implemented it.

[toc] | [prev] | [next] | [standalone]


#29903

FromTim Streater <timstreater@greenbee.net>
Date2016-03-11 12:13 +0000
Message-ID<110320161213384085%timstreater@greenbee.net>
In reply to#29899
In article <41dca990-88fe-4829-8fbb-fd8811727776@googlegroups.com>,
<jonas.thornvall@gmail.com> wrote:

>Here is the sample code someone suggested on net, and it makes you wonder.
>Do they require the input to come from a specific field in a form????

How about you try thinking for yourself and researching a bit better. I
assume you're doing this within an html document so how about:

  <body onkeydown="keydownHandler(event);">

and:

  function keydownHandler(e)
       {

       if  (e.keyCode==13)
            {
            // do stuff here when return pressed
            console.log ("x = " + x);
            }
       else if  (e.keyCode==20)
            {
            // Space pressed do something else
            }

       }


Simple enough.

-- 
"Once you adopt the unix paradigm, the variants cease to be a problem - you
bitch, of course, but that's because bitching is fun, unlike M$ OS's, where 
bitching is required to keep your head from exploding." - S Stremler in afc

[toc] | [prev] | [next] | [standalone]


#29907

From"Mr. Man-wai Chang" <toylet.toylet@gmail.com>
Date2016-03-11 21:52 +0800
Message-ID<nbuid2$3h9$1@dont-email.me>
In reply to#29896
On 3/11/2016 6:30 PM, jonas.thornvall@gmail.com wrote:
> I need to debug, and i real do not like the gist of firefox nor chrome debug.
> And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?

Webpages are not regular programs.. you should print debugging messages 
within the Javascript program.

-- 
   @~@   Remain silent. Nothing from soldiers and magicians is real!
  / v \  Simplicity is Beauty! May the Force and farces be with you!
/( _ )\ (Fedora release 23)  Linux 4.4.3-300.fc23.x86_64
   ^ ^   21:42:01 up 6 days 9:23 0 users load average: 1.01 1.05 1.05
不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

[toc] | [prev] | [next] | [standalone]


#29908

Fromjonas.thornvall@gmail.com
Date2016-03-11 07:29 -0800
Message-ID<8f51a0e4-2c4f-4ed0-99f2-23079596b4db@googlegroups.com>
In reply to#29907
Den fredag 11 mars 2016 kl. 14:52:37 UTC+1 skrev Mr. Man-wai Chang:
> On 3/11/2016 6:30 PM, jonas.thornvall@gmail.com wrote:
> > I need to debug, and i real do not like the gist of firefox nor chrome debug.
> > And i kind of like do my own debug printouts, how can i program javascript to wait for keyboard input?
> 
> Webpages are not regular programs.. you should print debugging messages 
> within the Javascript program.
> 
> -- 
>    @~@   Remain silent. Nothing from soldiers and magicians is real!
>   / v \  Simplicity is Beauty! May the Force and farces be with you!
> /( _ )\ (Fedora release 23)  Linux 4.4.3-300.fc23.x86_64
>    ^ ^   21:42:01 up 6 days 9:23 0 users load average: 1.01 1.05 1.05
> 不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA):
> http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

Well i do most often i write them to textareas, however the function that locks up also manage to reset the program. So my printout in textarea dissapear, and i have no possibility to see when it occurs ahead. 

So i was thinking wail for keyboard press would let me do the readouts from textarea until the thing hang and reset in loop.

[toc] | [prev] | [next] | [standalone]


#29909

FromStefan Weiss <krewecherl@gmail.com>
Date2016-03-11 17:00 +0100
Message-ID<nbuq32$gg0$1@news.albasani.net>
In reply to#29896
I'm going to reply to the first message in this thread, because I don't
know when you'll be done replying to yourself, and I don't want to
interrupt your conversation.

I'll just pretend it was all in one message.

On 03/11/2016 11:30, jonas.thornvall@gmail.com wrote:
> I need to debug, and i real do not like the gist of firefox nor
> chrome debug.

This right here is the main problem. Everything you ask for is already
available, but you can't be bothered to learn how the debugger works. By
far the simplest solution to your problem would be getting to know your
tools.

HOWEVER. In a previous thread, I have promised to give you one answer,
ignoring your idiosyncrasies, so I'm going to give it a try.

I'm going to focus on your desire to have sleep() and wait-for-event
functions that can pause and resume a program in the middle of a loop.

The reason why this doesn't exist natively in JavaScript is mostly
historical. JavaScript was created for use in browsers, and at the time
browsers were single-process, single-thread programs. Scripts or
functions were expected to run from start to finish without
interruption. While a script was running, everything else was paused
(often including the browser's user interface, leading to nasty
freezes), so a straight sleep() would be undesired.

UI programming in JavaScript is primarily event-based: delays are
implemented by setTimeout() and event listeners, both of which work by
executing a callback function. This works, and people have been using it
for a very long time. It does, however, require a different program
structure than you may be used to from Basic or Pascal.

That said, we have a different situation today, and I don't see a
compelling reason why sleep() or wait-for-keyboard should shouldn't be
possible. More on that below.

> To be honest i find it weird that you have to add a listener and on
> key handlers it is pretty much 20 linke of code that have to be
> written.
...
> Here is the sample code someone suggested on net, and it makes you wonder.
> Do they require the input to come from a specific field in a form????

It doesn't need 20 lines, and you don't need a form field to listen for
events. People usually wrap these things into reusable functions (or use
a library) to make it less verbose, but even in vanilla JS it's simple
enough:

    document.addEventListener("keydown", function (evt) {
        if (evt.keyCode == 13) {
            console.log("Enter key was pressed.");
        }
    });

That's all it takes in the minimal version.
But that's not what you're looking for, I know.

> Pseudcode.
> 
> wait until key pressed.
> 
> If you do not like wait(3000); 
> You could do something in the line already in language.
> setKeyInput(myFunction, keyPress="32")
> 
> But i prefer wait until(keyPress=="32") anyday of the year.
> And keyPress is a listener that can be turned on and off with boolean true/false.
> 
> So during execution you can chose function to be called from keyboard.
> if (keyPress=="32") exit();

I'm sorry, but it's not possible to implement your preference in
JavaScript. You can't just invent new syntax.

Here's something that's actually possible. Say you have a function with
a loop, and you want to pause the loop until the space key is pressed:

    function jonas (start, max)
    {
        for (var i = start; i <= max; i++) {
            console.log("i is now", i);
            wait until(keypress="32");     // syntax error
        }
        console.log("end");
    }

With a little generator magic, you can make individual functions pause-able:

    var jonas = S(function* (start, max)
    {
        for (var i = start; i <= max; i++) {
            console.log("i is now", i);
            yield jonas.waitKbd(32);
        }
        console.log("end");
    });

Now run jonas(3,5) and watch the output in the console.

Similarly, you can use other delays:

    yield jonas.sleep(1000);   // wait for 1000 ms
    yield jonas.waitMouse();   // wait for left click
    yield jonas.waitMouse(2);  // wait for right click

If that's an acceptable workaround for you, all you need is the S
function below and a current browser. Remember to

   1) use `var myFuncName = ...` instead of `function myFuncName`
   2) wrap your original function in a call to S()
   3) use function* instead of function


The following code provides these features. Paste it somewhere above or
below your own code.

    function S (genFun)
    {
        "use strict";

        var gen;

        function sleepyFun ()
        {
            if (!gen) {
                // gen = genFun(...arguments); // meh. FF bug #1067049
                gen = genFun.apply(null, arguments);
            }
            step();
        }

        function step ()
        {
            if (gen.next().done) {
                gen = null;
            }
        }

        function listen (evtName, cond)
        {
            function listener (evt)
            {
                if (evt && cond(evt)) {
                    document.removeEventListener(evtName, listener);
                    step();
                }
            }
            document.addEventListener(evtName, listener);
        }

        sleepyFun.sleep = function (ms) {
            setTimeout(() => step(), ms);
        };
        sleepyFun.waitKbd = function (key) {
            listen("keydown", (evt) => evt.keyCode == key);
        };
        sleepyFun.waitMouse = function (btn = 0) {
            listen("click", (evt) => evt.button === btn);
        };

        return sleepyFun;
    }


> how can a programming language be so convoluted

> the listeners ***seem?*** to suffer from proverbial diarrhea

> It piss me off to be Frank how one can convolute straight forward
> things into some mystic listener religion?

> Isn't it evolution a bit fucking weird when something that required
> one line of code suddenly need a library?

> Oh is see i need to learn an API so i can see what fucking key i pressed

> sad glimpse of a future

> sign of retardness

> nobody think about programmers

> What the fuck went wrong?

> anal beadhead

Yes, Frank, it's a horrible horrible language. They actually expect us
to learn APIs? Who do they think they are! That's probably the reason
why JavaScript is such a niche language today.

Having posted the promised reply, I will now return to my default state
of not answering questions unless the poster invests a minimum of effort
in readability and netiquette.


- stefan


PS (group): I hacked this function together rather quickly. It works,
but I'm sure it can be improved quite a bit. If you find anything, I'd
love to hear about it.

[toc] | [prev] | [next] | [standalone]


#29910

FromStefan Weiss <krewecherl@gmail.com>
Date2016-03-11 17:11 +0100
Message-ID<nbuqnf$h5u$1@news.albasani.net>
In reply to#29909
On 03/11/2016 17:00, Stefan Weiss wrote:
>         sleepyFun.waitMouse = function (btn = 0) {
>             listen("click", (evt) => evt.button === btn);
>         };

Whoops, default parameters aren't well supported yet... use this instead:

        sleepyFun.waitMouse = function (btn) {
            listen("click", (evt) => evt.button === btn || 0);
        };

- stefan

[toc] | [prev] | [next] | [standalone]


#29911

Fromjonas.thornvall@gmail.com
Date2016-03-11 08:32 -0800
Message-ID<9a63fd08-a0a6-4c23-8cd5-e3bd3a2076fc@googlegroups.com>
In reply to#29910
Den fredag 11 mars 2016 kl. 17:11:34 UTC+1 skrev Stefan Weiss:
> On 03/11/2016 17:00, Stefan Weiss wrote:
> >         sleepyFun.waitMouse = function (btn = 0) {
> >             listen("click", (evt) => evt.button === btn);
> >         };
> 
> Whoops, default parameters aren't well supported yet... use this instead:
> 
>         sleepyFun.waitMouse = function (btn) {
>             listen("click", (evt) => evt.button === btn || 0);
>         };
> 
> - stefan

I don't know if you realise it but both the situation and your answer suffer from a kind of sadistic humor that pass as tolerable ;). 

It kind remind me of a story from the former eastblock burecrazy where a person is sent around offices to find the correct form to apply to adhere to the bureaucratic procedure regarding his requirment form.
After working the maze bureacrazy he at last ends up in the office he started his request with the same form he initially brought there. 

But i guess anal people just can't see that.

You may not see the similarity but i for sure do. 

[toc] | [prev] | [next] | [standalone]


#29913

FromStefan Weiss <krewecherl@gmail.com>
Date2016-03-11 20:20 +0100
Message-ID<nbv5pn$6va$1@news.albasani.net>
In reply to#29911
On 03/11/2016 17:32, jonas.thornvall@gmail.com wrote:
> I don't know if you realise it but both the situation and your
> answer suffer from a kind of sadistic humor that pass as tolerable ;).

I was going for sarcasm rather than sadism, but I'm glad you found it
tolerable nevertheless.

> It kind remind me of a story from the former eastblock [...] 
> 
> But i guess anal people just can't see that.
> 
> You may not see the similarity but i for sure do. 

No, sorry, I don't see how that applies here. Do you think that calling
people who answer your questions "anal" is going to improve your chance
of getting help here? If that's not what you're looking for, I would
suggest switching medium: instead of Usenet, try Twitter - the UDP of
human conversation.

- stefan

[toc] | [prev] | [next] | [standalone]


#29912

Fromjonas.thornvall@gmail.com
Date2016-03-11 08:55 -0800
Message-ID<ec9a24dc-6b47-441f-85c3-bb868695c2f1@googlegroups.com>
In reply to#29910
Den fredag 11 mars 2016 kl. 17:11:34 UTC+1 skrev Stefan Weiss:
> On 03/11/2016 17:00, Stefan Weiss wrote:
> >         sleepyFun.waitMouse = function (btn = 0) {
> >             listen("click", (evt) => evt.button === btn);
> >         };
> 
> Whoops, default parameters aren't well supported yet... use this instead:
> 
>         sleepyFun.waitMouse = function (btn) {
>             listen("click", (evt) => evt.button === btn || 0);
>         };
> 
> - stefan

Sadly i think that Javascript is probably quite beautiful under the hood. Some where deep down there it is based upon sound principles, otherwise it would not have such rich functionality upon strings and arrays.

But sadly how weak and convoluted it ends up, when you put idiots to program the user interface, the actual program language. 

[toc] | [prev] | [next] | [standalone]


#29914

FromAleksandro <aleksandro@gmx.com>
Date2016-03-11 16:30 -0300
Message-ID<nbv66u$ko5$1@dont-email.me>
In reply to#29912
On 11/03/16 13:55, jonas.thornvall@gmail.com wrote:
> Den fredag 11 mars 2016 kl. 17:11:34 UTC+1 skrev Stefan Weiss:
>> On 03/11/2016 17:00, Stefan Weiss wrote:
>>>         sleepyFun.waitMouse = function (btn = 0) {
>>>             listen("click", (evt) => evt.button === btn);
>>>         };
>>
>> Whoops, default parameters aren't well supported yet... use this instead:
>>
>>         sleepyFun.waitMouse = function (btn) {
>>             listen("click", (evt) => evt.button === btn || 0);
>>         };
>>
>> - stefan
> 
> Sadly i think that Javascript is probably quite beautiful under the hood. Some where deep down there it is based upon sound principles, otherwise it would not have such rich functionality upon strings and arrays.
> 
> But sadly how weak and convoluted it ends up, when you put idiots to program the user interface, the actual program language. 

If you knew what you were talking about, you would know the UI events
have little do do with the actual language; they are merely an
implementation for a particular stack.

[toc] | [prev] | [next] | [standalone]


#29915

Fromjonas.thornvall@gmail.com
Date2016-03-11 11:46 -0800
Message-ID<b4240f95-40ec-4bee-ad9a-1cc4fe15273f@googlegroups.com>
In reply to#29914
Den fredag 11 mars 2016 kl. 20:30:40 UTC+1 skrev Aleksandro:
> On 11/03/16 13:55, jonas.thornvall@gmail.com wrote:
> > Den fredag 11 mars 2016 kl. 17:11:34 UTC+1 skrev Stefan Weiss:
> >> On 03/11/2016 17:00, Stefan Weiss wrote:
> >>>         sleepyFun.waitMouse = function (btn = 0) {
> >>>             listen("click", (evt) => evt.button === btn);
> >>>         };
> >>
> >> Whoops, default parameters aren't well supported yet... use this instead:
> >>
> >>         sleepyFun.waitMouse = function (btn) {
> >>             listen("click", (evt) => evt.button === btn || 0);
> >>         };
> >>
> >> - stefan
> > 
> > Sadly i think that Javascript is probably quite beautiful under the hood. Some where deep down there it is based upon sound principles, otherwise it would not have such rich functionality upon strings and arrays.
> > 
> > But sadly how weak and convoluted it ends up, when you put idiots to program the user interface, the actual program language. 
> 
> If you knew what you were talking about, you would know the UI events
> have little do do with the actual language; they are merely an
> implementation for a particular stack.

Well just as i told you, the idiots that implemented the eventhandler and listeners are not the same people that deigned the core language.

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web