Recycled QWA: javascript case randomize

Tuesday, 14 August 2007

<script type="text/javascript">//<![CDATA[
function curry (n) {
  if ( n.nodeType == 3 ) {
    n.data = scrambleCase( n.data );
  }
  var kids = n.childNodes;
  var str = '';
  for ( var i = 0; i < kids.length; i++ ) {
    var ret = curry( kids[i] );
    str += ret;
  }
  return str;
}
function scrambleCase (txt) { var wordish = txt.split(' '); for ( var i = 0; i < wordish.length; i++ ) { var w = new Array () for ( var n = 0; n < wordish[i].length; n++ ) { var letter = wordish[i].charAt(n); if ( ( Math.random() * 2 ) > 1 ) { letter = letter.toLowerCase(); } else { letter = letter.toUpperCase(); } w.push( letter ); } wordish[i] = w.join(''); } return wordish.join(' '); } //]]> </script>
digg stumbleupon del.icio.us reddit Fark Technorati Faves

Discussion

Comments


Jen

Re: Recycled QWA: javascript case randomize

Look look! I'm making the page dance! Too much fun...

I recently installed NoScript to make myself feel safer, and it's been eye-opening to see all of the <noscript> presentations and default behaviors for people who don't have javascript on. Yours is the winner so far. :)

By Jen on 14 August 2007 · 14:59
comment link · reply to this

Ashley

Re^2: Recycled QWA: javascript case randomize

I’m glad it got seen by someone besides a phishing bot. :)

By Ashley on 14 August 2007 · 19:04
comment link · reply to this

jody

Re: Recycled QWA: javascript case randomize

Nicely done! I didn't notice this was an interactive post when I read it via Google Reader. Get it working on buttons next!

By jody on 15 August 2007 · 03:44
comment link · reply to this

Ashley

Re^2: Recycled QWA: javascript case randomize

Thanks. Nothing as fun as stupid JavaScript.

You could probably do that—buttons—pretty easily but messing with form elements (the button input:value might be case sensitive) could break a page’s functionality.

By Ashley on 15 August 2007 · 04:15
comment link · reply to this

jody

Re: Recycled QWA: javascript case randomize

I tried for 5 minutes to incorporate into a post, but Wordpress doesn't like Javascript; I'd have to do some hacking and I haven't had enough coffee yet.

By jody on 15 August 2007 · 04:30
comment link · reply to this

Your information (required) Name*
Email*
Website

* Indicates required fields; email is used for validation and is not displayed on the site.

Your comment
Commenting on Recycled QWA: javascript case randomize
Title

Body is limited to ≈1,000 words. Paragraphs—but not line breaks—are automatically inserted. Valid XHTML is required. These are the allowed tags–

<a href=""></a> <br/> <acronym title=""></acronym> <abbr title=""></abbr> <code></code> <pre></pre> <tt></tt> <ins></ins> <del></del> <hr/> <cite></cite> <b></b> <i></i> <sup></sup> <sub></sub> <strong></strong> <em></em> <h1></h1> <h2></h2> <h3></h3> <q></q> <blockquote></blockquote>