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


Groups > comp.lang.javascript > #11180

Re: Misspelling Can Bite You

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Dr J R Stockton <reply1205@merlyn.demon.co.uk>
Newsgroups comp.lang.javascript
Subject Re: Misspelling Can Bite You
Date Fri, 3 Feb 2012 22:49:58 +0000
Organization Home
Lines 54
Message-ID <clw4wWGWSGLPFw+L@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <po1mi75fb0u5rqp9or413nv26799lpnndj@4ax.com>
NNTP-Posting-Host JfH6RRPWQh8XzArFI0xgxA.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain;charset=us-ascii
X-Complaints-To abuse@aioe.org
User-Agent Turnpike/6.05-S (<h47ExRUkcs8NDA9ubu0bCn8oOW>)
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:11180

Show key headers only | View raw


In comp.lang.javascript message <po1mi75fb0u5rqp9or413nv26799lpnndj@4ax.
com>, Thu, 2 Feb 2012 14:02:39, Gene Wirchenko <genew@ocis.net> posted:

>     Once again, it is time to thank me for pointing a possible source
>of errors in JavaScript code or to chuckle over how I messed up again,
>maybe both.
>
>     I misspelled the name of the control variable for a switch.  I
>had
>          switch (this.DateType)
>when it should have been
>          switch (this.DataType)
>
>     JavaScript was quite happy to execute the code.  After all, the
>switch might have had a case to handle undefined.



Putting the following script element last, or making it a body onload
function, will list all the script words of more than 2 letters, in
alphabetical order, with the number of times used.  The result will be
browser-dependent; but not gravely so.  Demo in my js-misc1.htm.


<script type="text/javascript">

  var skripts = document.getElementsByTagName("SCRIPT")
  var L = skripts.length, Str = "", Out = []
  while (L--) Str += skripts[L].innerHTML
  Str = Str.split(/\W+/).sort()
  var was = "", K = 0
  L = Str.length
  while (L--) {
  if (Str[L] == was) K++ ; else {
    if (was.length > 2 && /^[a-z]/i.test(was)) Out.push(K + "  " + was)
    K = 1 ; was = Str[L] } }
  document.write("<pre>" + Out.reverse().join("\n") + "<\/pre>")

</script>


The code could, no doubt, be optimised.  The output might better be to a
textarea or a new page.  It could be well to NOT scan words in strings
or comment.


Code could be added to pick out cases where two adjacent words are
unreasonably similar.

-- 
 (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.

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


Thread

Misspelling Can Bite You Gene Wirchenko <genew@ocis.net> - 2012-02-02 14:02 -0800
  Re: Misspelling Can Bite You "Richard Cornford" <Richard@litotes.demon.co.uk> - 2012-02-03 01:37 +0000
    Re: Misspelling Can Bite You Gene Wirchenko <genew@ocis.net> - 2012-02-02 18:09 -0800
    Re: Misspelling Can Bite You Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-03 04:15 +0100
  Re: Misspelling Can Bite You Dr J R Stockton <reply1205@merlyn.demon.co.uk> - 2012-02-03 22:49 +0000
    Re: Misspelling Can Bite You "Mel Smith" <med_cutout_syntel@aol.com> - 2012-02-04 13:21 -0700
      Re: Misspelling Can Bite You Dr J R Stockton <reply1205@merlyn.demon.co.uk> - 2012-02-05 16:59 +0000
        Re: Misspelling Can Bite You "Mel Smith" <med_cutout_syntel@aol.com> - 2012-02-06 10:28 -0700
          Re: Misspelling Can Bite You Dr J R Stockton <reply1206@merlyn.demon.co.uk> - 2012-02-07 21:54 +0000

csiph-web