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


Groups > comp.lang.javascript > #21197

Re: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral

From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral
Date 2013-09-08 02:04 +0200
Organization albasani.net
Message-ID <l0getk$ksp$1@news.albasani.net> (permalink)
References <2c5d4c48-eb2b-4ade-9a00-6dc5f50c8c87@googlegroups.com> <4L3Y5fIEr4KSFwEb@invalid.uk.co.demon.merlyn.invalid>

Show all headers | View raw


On 2013-09-07 22:21, Dr J R Stockton wrote:
> FOR OTHERS ALSO :
> 
> My pages contain shown code actuated by buttons.  Usually, it is thought
> to be obvious that a given button just calls a certain function

It's the most common case, but with event bubbling and capturing, and
the possibility of attaching multiple listeners to an event, no such
assumption should be made.

> I have something partly like the following Form, in js-misc0.htm#SE :
> 
> <form action="#">
> 
>  <input type=text name=X size=6 value=333>
> 
>  <input type=button value=" B " onClick="TA1.value=EratoB(+X.value)">
> 
>  <input type=button value=" ? "
>   onClick="TF=this.form ; eval(this.title)"
>   title="TF.TA1.value=EratoB(+TF.X.value)">
> 
>  <br><textarea name=TA1 rows=6 cols=66 readonly></textarea>
> 
> </form>
> 
> 
> There, the buttons do the same when clicked, except that the second
> pollutes TF, wherever that may be, and hovering over the button reveals
> its effective code.

Without leakage:

 <input type=button value=" ? "
  onClick="eval('TA1.value=' + this.title)"
  title="EratoB(+X.value)">

Still shows the relevant code in the title (which, I think, is what you
wanted).

> Untested : I suppose that I can use  onClick="Oozlum(this)" and define
> Oozlum elsewhere.

Of course you can. Personally, I would much prefer a helper function,
compared to relying on the rather unintuitive identifier resolution in
event attributes (even more so in form elements).

> Any suggestions for improvements?  TNNR.

If two buttons (or two *anything*) do the same thing, they should be
combined into a single function (DRY). You can still eval() code from
there, if you must.

- stefan

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral jonas.thornvall@gmail.com - 2013-09-06 01:12 -0700
  Re: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral Ken <usenet-so@abdiassoftware.com> - 2013-09-06 18:37 -0500
    Re: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral jonas.thornvall@gmail.com - 2013-09-06 23:15 -0700
  Re: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-09-07 21:21 +0100
    Re: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral Stefan Weiss <krewecherl@gmail.com> - 2013-09-08 02:04 +0200
      WAS: Make an anime that draws primes different from offsets number++ , it's a variant of ulam spiral Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-09-09 19:38 +0100

csiph-web