I'm excited to announce a completely redesigned JavaScript console for GI Builder. The implementation comes courtesy of community member Eric Shi, who deserves much praise for stepping up and contributing this code.
Here is the JIRA ticket: http://www.generalinterface.org/bugs/browse/GI-421
The new JS console borrows heavily from the Safari Error Console. We really like how the Safari console works so we thought we'd port it to GI Builder so it can run on every browser that Builder supports.
One of the first things you'll notice about the new JS console is that it displays a running list of commands and command output. This is what makes it a "console." In our experience this is much more useful than the test utility in GI 3.8, which only shows the last command and its output.
When focused in the console prompt use the up and down arrow keys to scroll through the command history. This works even across restarts of Builder!
The other key feature of the new JS console is the ability to drill down into nested data structures that a command outputs. For example, enter the command "document.body" or "jsx3" and you'll see the string representation of an object and a collapsed arrow to its left. Click on the arrow to expand the object. Any nested objects can themselves be expanded, indefinitely. Useful hint: property keys are shown in purple except when the value of the property is inherited from the object's prototype, in which case the key is shown in gray. Function and Array outputs are also printed intelligently. No more will you see the cryptic and unhelpful "[Object]" when evaluating a JavaScript expression.
If you ever want to clear the console history just type Ctrl+K or right click on the console for a context menu.
By default the console evaluates the input any time you press the Enter key. The console does support multiline input either by pasting the multiline text at the prompt or by typing Shift+Enter to insert a carriage return.
Eric also implemented GI-705 in the new console, which I described previously in this blog post.

A note about execution context: all code evaluated by the JS console is execute in window scope. That means if you evaluate a statement like:
f = 1;
you have actually set the property f of the top-level object window. If you set a global variable in this way it is available to subsequent expressions that you evaluate in the console. Note that the form var f = 1; does not have the same behavior as f = 1;. The value of f will not be available to subsequent expressions if set in this way.

Comments (5)
Nov 10, 2009
Tony Lefebvre says:
Nice, very excited :) Can we have this Javascript console from any GI applicati...Nice, very excited :)
Can we have this Javascript console from any GI applications (like we can pop up the Monitor with CTRL+ALT+M) ?
Sometimes, when using the application outside of GI Builder, one want to retreive or change some value on the fly. I remember this neat feature in Quick Basic when one can break the program and then execute some additionnal code (aka. Immediate ).
Let's have a CTRL+ALT+ J ?
Nov 17, 2009
Jesse Costello-Good says:
Well, if you're writing an AMP app then it would be really easy to copy the plug...Well, if you're writing an AMP app then it would be really easy to copy the plug-in from Builder to your own app. I think that a runtime debug console would be a great new feature, probably for GI 4.0.
Nov 20, 2009
Darren Hwang says:
You could also just run Firebug.You could also just run Firebug.
Apr 15
Darren Hwang says:
Actually one peeve I have is that pressing "Enter" execute the code instead of a...Actually one peeve I have is that pressing "Enter" execute the code instead of adding new line. Most of the time I'm writing a muti line script and I don't remember to use "Shift+Enter" (as I figure it out later) to create the new line and end up rewriting multiple times (yes, I keep pressing enter every time I want new line and have to redo it every time).
The default behavior for "enter" key should be new line and "ctrl+enter" to execute.
BTW, I'm not the only one .. I've talked to many users.
Apr 30
Tony Lefebvre says:
Agree. Can it be an option in the IDE Settings ?Agree. Can it be an option in the IDE Settings ?