Subscribe to

Archive for the 'JavaScript' Category

Scripted Screenshots

I recently needed to make a screenshot of an entire web page, i.e. not just the part the fits on the screen (or in the viewport), but the whole thing from top to bottom. Somehow I missed the possibility that there might be a zillion browser extensions for just this purpose. From writing features (acceptance […]

The DOM change notification I presented yesterday is one piece in the puzzle to rejuvenate my languishing JavaScript form validator. I’ve not yet made up my mind on a lot of issues, but there’s one thing that’s certain: the next version will have to be able to work with changing forms, that is, forms that […]

So we’ve put in the effort to make our JavaScript code nicely unobtrusive and all is well — until it isn’t. A pesky Ajax request has messed up the DOM and suddenly there are elements in there where our unobtrusive behavioral goodness has not been attached. Never give up, never surrender. You won’t even have […]

JavaScript FSM v0.2.2

I’ve released a new version, 0.2.2, of the JavaScript FSM builder. There are some enhancements, such as accessors for successorStates and expectedEvents that I found useful for implementing a first (almost) practical example involving drag & drop. Speaking of which, this whole thing didn’t come into being because of a pressing need. Currently, it’s more […]

I like finite state machines and I wanted to try metaprogramming in JavaScript ever since I’d seen Adam McCrea presentation on the topic. The result is an FSM builder in JavaScript. Machine descriptions look like my test machine here: var Machine = { with (fsm) { onUnexpectedEvent(function() { … }); state(‘start’, ‘initial’) .event(‘go’) .goesTo(‘middle’) […]

Make your layout look good a different screen and font sizes. What it looks like Example 1, Example 2. Here’s what the form example (example 1) is supposed to look like. At 1024 x 768 pixels, the navigation links and Save button are positioned fixed in a column to the left. At 800 x 600 […]

On my continuing quest to become more Web-2.0-ish, I’ve tried my luck tilting at… well, tag clouds. To get an idea what I’m talking about, please have a look. These are the rudimentary basics to create a tag cloud like that. In the controller def tags @popular_tags = Tag.find_most_popular(:limit => 30) end In the view […]

Auto-completion for tag lists

See the end of this post for an important update. Standard Rails auto-completion is geared toward completing a single value entered in a text field. For most cases this is exactly what’s needed, but there is one prominent case that is different: auto-completion of tags. If something can have a tag at all, it’s part […]

Ruby on Rails already does a good job of specifying almost declaratively what conditions objects must meet to be considered valid–that is, how they are validated. Thus, in order to make sure that a Person’s last_name attribute does not exceed 100 characters, you would write something like this class Person < ActiveRecord::Base validates_length_of :last_name, :maximum […]

Fork me on GitHub