Tom Pierce's Blog : Let the geek times roll.
Updated: 6/20/04; 3:22:31 PM.

 

Subscribe to "Tom Pierce's Blog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Thursday, March 25, 2004

I'm sure that most people who are web savvy developers have experienced the greatness that is VisiBone's online color lab.  Not being particularly front-end studly, this is new to me.  I like to be able to pick the complementary colors by looking at the pretty hex wheel thingy.  Mmmm...  colors.
3:52:52 PM    comment []

Ever had to write alot of JavaScript?  Better yet, ever inherit alot of JavaScript and not have time to fully understand what it does?  Best - have you ever inherited alot of JavaScript that you don't have time to understand and have to quickly figure out how to extend it?  Well, I HAVE! 

Currently I'm on a project that is built on top of a framework that contains a non-trivial amount of JavaScript.  Normally this would be OK, but I have to actually extend the framework a little for the current project.  And, normally this would be OK (with another language) because you would have tools like compilers, debuggers, and friendly editors that make it easier.  However, we're talking about JavaScript.

So, I had this problem.  I had edited a JS file used by my web app and I expected the goodness to just start flowing.  However, it seemed as if the browser (IE) was not even loading the file.  When I debugged (with Visual Studio Script Debugger), I could evaluate some expressions that lead me to believe none of the functions in that entire file had been defined.  Hmmm...  Why wasn't it reading the file - the declaration in the HTML looked correct.  What's going on?

That's when I started thinking I had some sort of syntax problem with the JavaScript in the file.  But, I didn't know how in the world I could figure it out without a compiler or some kind of LINT tool.  Maybe if I could just find a parser and see if it puked on my file...

Enter RhinoRhino is an open source implementation of JavaScript written in Java and is part of the Mozilla project.  Not only does Rhino contain a JavaScript parser and evaluation engine, but it also contains a JavaScript debugger and interactive shell.  YES!!!

As soon as I tried to load my JS file into the debugger, Rhino told me I had a problem.  The error said I had a missing variable name.  I could tell from the error message that the #288 on the end meant that it was on line 288.  So, I went to line 288 in my JS file:

var default = defaults[0].split("@@");

Hmmm.   That looks fine to me.  What's going on?  Have I used some kind of reserved word as a variable?  So, I switched over to the JavaScript Console window and entered default at the prompt.  Syntax error.  Well, what happens if I enter an undeclared variable like "dude"?  An error telling me "dude" is not defined.  AH HA!  So I have used some kind of reserved word.

So, long story (not so) short, I edited the JS file and changed var default = ... to var defaultFilter = ...  and Rhino read it just fine.  YEEE HA!  Back to the web page.  I fire up my browser, point to my web page and BAM!  No more JavaScript error.  After at least 2 shameful hours of head scratching that left me on the brink looking over at insanity below, the Rhino pulled me back to safety. 

Thank you Rhino...  thank you.

 


8:14:56 AM    comment []

© Copyright 2004 Tom Pierce.



Click here to visit the Radio UserLand website.

 


March 2004
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Feb   Apr

Search

[sgl dagger]
How this works

Emacs Sources
 tsql-indent.el
 user-add-sql-folding-marks
 remove-line-boundary-in-region
 convert-camel-to-underscore

My Subscriptions
 Funny
 KM