February 28, 2008

Browser JS Stack Limits

Safari had such a tiny stack at the time this was posted:

Novemberborn: Maximum Call Stack Size in Modern Day Browsers

I've tried it with a more recent version of Safari 3.0.4 and I found:

"Maximum call stack size: 500"

According to the test at http://tests.novemberborn.net/javascript/callstack-size.html .

That's better, but is it enough? I'm a little surprised that Firefox doesn't have the biggest stack of them all. Maybe size isn't everything.

Posted by lsloan at 10:40 AM | Comments (0)

February 24, 2008

Fantastic JS Dialog Boxes

Based on Prototype, but not script.aculo.us, this modal dialog box for JS is very good:

Prototype Window Class : Introduction

Posted by lsloan at 10:11 PM | Comments (0)

February 20, 2008

Prototype & script.aculo.us Book/PDF

When one day I commented that the script.aculo.us wiki was down yet again, the author of this book suggested that I buy it:

The Pragmatic Bookshelf | Prototype and script.aculo.us

The nice thing is that it is sold as a combination paper book and PDF file. No need to lug around a book if it's not convenient.

Posted by lsloan at 08:58 AM | Comments (0)

February 19, 2008

Scriptaculous Popups

Looking for some JS popups based upon Scriptaculous and Prototype, I looked at script.aculo.us first. Sadly, a lot of their information is in their wiki, which happened to be unavailable for some reason!

I turned to Google and I found:

DOM Popup Kit which makes its own links and requires popup contents to be defined ahead of time.

ModalBox looks better and it appears to do well called from a JS event attribute and can load dynamic content. It also handles static content well, either directly or by reference.

MOOdalBox is supposedly an altered version of ModalBox that looks pretty nice, too.

Intro to Scriptaculous Effects is not a real popup widget, but is a nice introduction to using the JS library.

There are probably others, but I think these are a good start.

Posted by lsloan at 11:46 PM | Comments (0)

June 14, 2007

Lightbox: JS Image "Pop-up"

Lightbox looks like a nice way to make images pop-up within the same browser window on most modern JS-enabled browers. Browsers without JS will treat the link as it normally would. One could easily construct the link to open the image in a new window.

Lightbox JS

Posted by lsloan at 09:10 AM | Comments (0)

December 15, 2006

MochiKit In-Place Editing (Not Quite)

In his only blog post, Jakub shows this stub for in-place editing with the MochiKit JS library:

function make_editable(elem) { 
   function inplace(e) {
      var obj = getElement(elem);
      var editable_id = '_'   (new Date).getTime()   '_textarea';
      swapDOM(elem, TEXTAREA({id:editable_id, cols:40, rows:5}, obj.innerHTML));
      connect(currentDocument(), 'onkeydown', function(e) {
	 var textarea = getElement(editable_id);
	 var key = e.key().string;
	 if (key == 'KEY_TAB') {
	    obj.innerHTML = textarea.value;
	 }
	 if (key == 'KEY_ESCAPE' || key == 'KEY_TAB') {
	    disconnect(currentDocument(), 'onkeydown');
	    swapDOM(editable_id, obj);
	 }
      });
   }
   connect(elem, 'onclick', inplace);
}

The only problem is, in his post he said it uses Ajax, which it doesn't. This is a good start on the user interface, though. It would be nice to see a completed version of this. (Perhaps as flexible as the one in strict.aculo.us?)

Posted by lsloan at 12:14 PM | Comments (0)

December 08, 2006

Ajax Roundup: Yee-ha!

Git yer doggies ready fer the
The AJAX Framework Roundup!

This article should help pick out the right Ajax framework. At least for the next few days. Then the frameworks will change again.

I'm afriad to pick out a favorite framework, because when I do, I find that another one has some cool features, better implementation, etc.

However, there's absolutely no mention of MochiKit! Not just in that section, either. It's not discussed anywhere on devx.com.

Posted by lsloan at 10:57 AM | Comments (0)

Ajax Support in Rails

The IBM developerWorks article
"Crossing borders: Ajax on Rails" (Why Ajax works so well with Ruby), is another reason to check out Ruby on Rails.

I've been using a bit of script.aculo.us Javascript libraries in some of my own projects. A major discussionforum about it is on Google Groups, under the name "rubyonrails-spinoffs". So this article comes as no surprise. However, the example they use in it (getting the time of day) is a little boring.

Posted by lsloan at 10:40 AM | Comments (0)

December 07, 2006

Partial Success with Eclipse ATF & Mac OS X

Inspired by the article "Discover the Ajax Toolkit Framework for Eclipse" on IBM developerWorks, I set out to try to make it work for me under Mac OS X. I have achieved partial success. I can create a project with Dojo components, but I'm unable to run it in the Mozilla browser embedded in Eclipse.

Part of the problem is that the Mac OS X version of XULrunner isn't a finished package yet. There's no clear documentation for installing or setting it up, so I just had to guess. When I downloaded it (xulrunner-1.9a1.en-US.mac-pkg.dmg) and mounted the disk image, I found that it didn't contain a Mac .pkg as the name suggested. It contained a XUL.framework folder, whose name and contents suggested it should belong in /Library/Frameworks. I put it there, but I was unable to find the appropriate installation command.

The very spare ATF download/install instructions said that I should run "sudo ./xulrunner --register-global", but doing so resulted in the message "Registration not implemented on this platform!"

So, I just hope it's in a good place to use it. However, after creating my sample Dojo application, attempting to run it tells me that Mozilla couldn't be started because XULrunner can't be found. At least running it does get the project published to my web server directory, though. However, any attempt to run it a second time causes Eclipse to crash. I wish I knew how to cause the project to get published without Eclipse attempting to run Mozilla.

I'm sure there are newsgroup or mailing list conversations out there about this. If only I could find them...

PS: When I wanted to download the ATF extension, I found only versions for Windoze and Linux. I reasoned that Linux is closer to Mac OS X than Windoze is, so I downloaded the binary and source combination package for Linux.

Posted by lsloan at 10:21 AM | Comments (0)

December 04, 2006

Custom Scrollbars

Some folks like to create custom scroll bars for their content that match the design of the web site better than the ones provided by the web browser or OS. Some of the solutions look good and work well, but I've yet to find any that support cursor keys, page up/down keys, or mouse scroll wheels. Personally, if those features aren't supported, I wouldn't use custom scroll bars on web sites I develop.

A post on the Google groups "Ruby on Rails: Spinoffs" got me interested enough to look at some examples:

Google Groups: Ruby on Rails: Spinoffs


The poster's own site describes what they used:

J-Log � Custom Scrollbars


This other one explains how theirs works:

Agave Group � Blog Archive � Scrollable DIV (and Blog Organization)

This one has some fancy features:

jsScrolling

Posted by lsloan at 11:42 AM | Comments (0)

November 08, 2006

MochiKit.Animator

The web page for
MochiKit.Animator Demos
may not look as fancy as some sites, but the toolkit it's hawking is very clever. It's a Javascript library for animating elements of a web page using DOM and CSS.

This is a spoiler, but see the Fisheye demo at the bottom of that page. I'm no big fan of the magnification effect in the Mac OS X Dock, but it's amusing to see it in use on a web page.

Posted by lsloan at 08:33 AM | Comments (0)

October 23, 2006

Javascript 1.7 in Firefox 2.0

New in JavaScript 1.7 - MDC

So Firefox 2.0 will support Javascript 1.7. As I read through that page of JS 1.7 features, a lot of it (array comprehensions, generators, iterators, etc.) remind me a lot of features in Python.

Other languages support those features, too, but Python's what I'm most familiar with.

Posted by lsloan at 12:16 PM | Comments (0)

April 19, 2006

Javascript That Reads Itself

This evening, while experimenting with Javascript DOM calls, it occured to me that if the JS could find the node for the script element, it may be able to read the code within it. Sure enough, the text, innerHTML, and textContent attributes of an inline script element node contains the Javascript code. That could make for some interesting introspection capabilities and possibly even Javascript that rewrites itself.

However, the same does not hold true for script elements that load their code from another source, using a src attribute and URL. There doesn't seem to be any way to access the code of that kind of script element. At first, I thought it must be the browser security in action, similar to that of iframe content loaded from a different domain. But I've found that this doesn't work even if the Javascript is loaded from the same domain as the page.

I was really hoping that Javascript could access the contents of such script elements. If it could, then I could add a script element to load any document, not just Javascript, then access its contents though the DOM.

Oh well, even if it were possible, it probably would be a security hole. I wouldn't be able to make use of it for very long before it got plugged.

Posted by lsloan at 12:06 AM | Comments (1)

April 15, 2006

Alternative to Many JS DOM Calls

As many folks will tell you, manipulating a document's content by modifying its various innerHTML properties can be problematic. A safer way is to use DOM calls. But it can be a pain to write a lot of DOM calls. There's no shortage of libraries to simplify this task, though.

Vivabit DOM Builder looks like a good example.

Posted by lsloan at 06:17 AM | Comments (0)

April 05, 2006

Javascript Closures

As part of my learning about Ajax, I ran across an article that explains Javascript Closures. It's not a well-written article as far as English grammar and readability, but it does offer a good amount of technical information. I found the section on execution contexts to be pretty interesting.

Posted by lsloan at 09:36 AM | Comments (0)