No more Javascript for me!

Well, I’ve been doing this web developer thing for a while now. And honestly, I’m just getting kind of tired of it. I mean, really. It’s starting to get boring. So, I was so happy to see that Google has created CADIE, a Cognitive Autoheuristic Distributed-Intelligence Entity. And the awesome thing is that she can write your code for you. So, now I’m just going to have CADIE write all of my Javascript for me.

Here’s a sample of some of my new code…

DO :3 <- '"'"'"'".1$':1~#32768'"~"#1109$#1"'$':1~#128'"~#2735'$
     ':1~"#546$#0"'"~"#43679"'$':1~"#1365$#0"'"~"#1023$#63"'$
     '"'"'".1$#0"~#34959'$':1~"#0$#1170"'"~#11007'$':1~"#0$#2925"'"~
     "#2005$#255"'

INTERCAL 4EVAR!

Yea, I know, this is so not original, but no one is these days, right?

What’s the Difference Between Equal and Identical?

Is it just me, or does saying equal seem to be the same as saying identical? Actually, it’s not, and I’ve struggled with understanding this for a while, until now! I figured out that they were different, through Javascript. The == and === comparison operators are not the same.

Here are the differences in definition in the Merriam-Webster’s Online Dictionary:

equal
      1. of the same measure, quantity, amount, or number as another
      2. identical in mathematical value or logical denotation : equivalent
    1. like in quality, nature, or status
    2. like for each member of a group, class, or society
  1. regarding or affecting all objects in the same way : impartial
  2. free from extremes: as
    1. tranquil in mind or mood
    2. not showing variation in appearance, structure, or proportion
    1. capable of meeting the requirements of a situation or a task
    2. suitable
identical
  1. being the same : selfsame
  2. having such close resemblance as to be essentially the same
    1. having the same cause or origin
    2. monozygotic

I guess I thought these definitions should be the same, in Javascript, because equal is identical in mathematical value or logical denotation. It turns out that in Javascript, equal is identical in value, but not necessarily in type. So, they are different.

Here’s the short, simple, Javascript explanation:

if ("1000" == 1000) {
     alert("They are equal");
} else {
     alert("They are not equal");
}

This code will show an alert box that says “They are equal”. But, let’s try this:

if ("1000" === 1000) {
     alert("They are identical");
} else {
     alert("They are not identical");
}

This code will show an alert that says “They are not identical”, because they are different types. One is a string and the other is a number.

if ("1000" === new String(1000)) {
     alert("They are identical");
} else {
     alert("They are not identical");
}

This will show an alert box saying “They are identical”. They are now both strings.

Get it? Got it? Good!

Prototype to Dojo – Where’s the findElement method?

Recently, I’ve had a chance to work on a project that uses Dojo as it’s Javascript framework. Prior to this, the only Javascript library I’ve used has been Prototype, along with Scriptaculous. Since I’ve been using Prototype for a while, there are some things I’ve gotten used to and now find useful to quickly create scripts. One of these things is the findElement method.

I primarily use Event.findElement to ensure that I’m getting the element I need from an event. So, if I have some DOM elements that look like the following:

<ul>
     <li id="animals"><a href="/animals/">Animals</a></li>
     <li id="children"><a href="/children/">Children</a></li>
</ul>

I might have a click event on both the li and a elements. However, I might need to get the id just from the li element. Getting that id in Prototype is simple. I would just create a function that looks something like the following:

function getIdFromLi(evt) {
     return evt.findElement('li').id;
}

So, if the user clicks on the a element, findElement would look for the li by first looking at the element that was clicked on and then going up from there. So, it would find the li element as the parentNode of the a element.

I haven’t been able to find something like this in Dojo. So, I found the element I needed like this:

function getIdFromLi(evt) {
     var liElement = evt.target;
     while (liElement.tagName.toLowerCase() !== 'li') {
          liElement = liElement.parentNode;
     }
     return liElement.id;
}

Do you know if there’s anything like this in Dojo? I couldn’t find it, can you?

Happy Birthday to Me!

So, here we are, on Tuesday, January 13th, 2009. It’s my birthday. Oh wow, it’s my birthday. Oh wow, I’m old. Oh well, that’s life.

My birthdays aren’t usually a very happy experience for me.  Just a reminder that I’m getting older and that I still haven’t done everything I wanted to do at this point in my life.  So, to make my birthdays more bearable, I get myself a gift, every year.  I’ve been doing this since high school.  I usually get myself a new outfit to wear on my birthday.  But last year, instead of doing that, I just threw myself four separate birthday parties.  That was fun!

Anyway, this year, I did my usual birthday outfit shopping yesterday during lunch.  I went to Anthropologie, my favorite store, and bought myself a new dress.  Yes, a dress!  Fear my pasty white legs!

I also did a little more.  I created a new site.  Yes, a new site!  The one you’re reading right now!  So, not only am I getting a gift this year, but you are too.  And it’s a site about, you guess it, me!  I want it to be a place for me and you to keep track of my communication and to keep me motivated to work on projects that I enjoy working on. So, this is strimble.com. My newest site. I hope you enjoy it!

Twitter Search Effects

The Twitter Search section currently seen on http://strimble.com/.

So, I’m not sure if you’ll notice or not, but last night I changed the index page a bit.  I removed the Election Results widget (BTW… Obama won! Yay!) and made some changes to the Twitter Search section.  To get the Twitter Search results, I’m just firing off an Ajax request to a PHP script on my site that gets the JSON feed from Twitter Search.  Then I’m displaying the first five results on the index page.  So, last night I added some effects.  It now checks the JSON every 1000 milliseconds to see if there’s a new post to display.  If there is a new post, it will slide up and fade the bottom post, slide down the new post, and then briefly highlight the new post.  If you actually have the chance to see it on the site, let me know what you think.  Questions and suggestions are always welcome.