warning: Creating default object from empty value in /home/kourge/ on line 34.

Cross-Domain Requests and Prototype

Ever since 3.5, cross-domain HTTP requests have been supported in Firefox. Getting this to work may seem easier and saner than piggy-backing Flash ("simply request a URL of different origin in your XMLHttpRequest!"), but unless you use jQuery, you'll realize that for some reason, cross-domain requests mysteriously fail in your JavaScript framework despite the fact that the server is correctly responding with an appropriate Access-Control-Allow-Origin header.

Prototype Essentials: just the essence

One of my recent efforts is Prototype Essentials. It is, pardon my pun, essentially Prototype stripped of its browser-specific parts such as Ajax, DOM stuff, selectors, form helpers, and an event system. Why would anyone want a stripped down version of Prototype?

The big idea is that sometimes your preferred JavaScript library or your JavaScript environment has an underpowered API when it comes to pure programming. I'll draw two of my personal examples. I find jQuery to be awesome for intuitive DOM traversal and manipulation, but when it comes to non-DOM objects, what jQuery can do is limited (and also, in my own opinion, not as intuitive). Drupal is a great platform to build web apps on, but its simplicity (bundling jQuery) comes with a cost, and I find myself constrained because of this. Not anymore.

My second example is when I'd like to throw together a quick and dirty shell script using JavaScript on Rhino. I frequently find myself in need of an intuitive way to get the last element of an array (Array.last in Prototype), interpolate strings (String.interpolate in Prototype), or construct ranges ($R or ObjectRange in Prototype). Now all I need to do now is load Prototype Essentials and I'd have a much richer set of utilities.

So please check out the website I set up for Prototype Essentials. I also plan to wrap this into a Drupal module so I can ease my pains (and hopefully those of others) in JavaScripting in Drupal.

Snippet: Font Detection with Prototype

This is essentially a clean house implementation of the font detection method described at lalit dot lab using Prototype 1.6. Another method described at seems very interesting, since it uses Flash.

This is only usable after the DOM is ready. Call Font.detect with a string containing the name of the font to be detected. If it's detected as present, true is returned, otherwise, false.

Spellify: How Not To Use Prototype

About two and a half weeks ago I wrote about jQuery being underutilized. That's nothing compared to Spellify, the absolutely perfect and horrendous example of how grossly unutilized Prototype is. Read on.

Libraries: On Size and Usage

As beginners, people who write Ajax applications (for the first time) tend to blindly slap on the Prototype JavaScript framework because of its fame and popularity. What then follows is the usual complaining on Prototype's size (over 60 kilobytes).

Prototype Breaks Not

The recent Ajaxian post on Prototype mentions how most people argue Prototype's badness. The first point is the most common: breaking the loop.

Ribbon Component for Prototype

I'm working on a Ribbon component that utilizes Prototype. The Ribbon I'm referring here is the Ribbon UI in Office 2007. Toolbars are passé.
Here is a highlight on the key features of the Ribbon component:

  • Multiple tabs, multiple groups
  • Collapsible
  • Stickybar that is persistent to the left (like the "Quick Access Toolbar" in Office), and a specific Help button
  • Detects mouse wheel scrolling and switches tabs
  • Supports different modes where different tabs are available

Prototype's Synchronous Quirk

I was experimenting with Prototype's AJAX call, but with the option asynchronous: false. It was buggy under Internet Explorer, although I never expected anything to work under Internet Explorer anyway.

Either Prototype never finished the XMLHttpRequest, or Prototype didn't call the function it was supposed to after the request.

Prototype: Enable/Disable Elements

I have written some code for Prototype. Prototype can toggle, show, hide, and remove elements (these are just one of the many features Prototype can do to elements).

I went even further: making it possible to disable, enable (if it's already disabled), and toggle disable elements. This is the code. (It's under the same MIT-style license as Prototype)

Syndicate content