Archive for January 2008
JSON 2.0: Libraries and browser support
John is at it again, writing a piece on recent news surrounding JSON.
He links to an updated library by Douglas Crockford, JSON2.js, that differs from the first version by using “a single base object (JSON) instead of extending all native object prototypes”.
-
-
JSON.stringify({name: “John”, location: “Boston”});
-
// => "{‘name’:'John’,'location’:'Boston’}"
-
JSON.parse(“{‘name’:'John’,'location’:'Boston’}”);
-
// => {name: "John", location: "Boston"}
-
It also turns out that Mozilla implemented this functionality in the browser (time for a wrapper):
-
-
var nativeJSON = Components.classes[“@mozilla.org/dom/json;1″]
-
.createInstance(Components.interfaces.nsIJSON);
-
nativeJSON.encode({name: “John”, location: “Boston”});
-
// => "{‘name’:'John’,'location’:'Boston’}"
-
nativeJSON.decode(“{‘name’:'John’,'location’:'Boston’}”);
-
// => {name: "John", location: "Boston"}
-
And in conclusion:
The final, and most important, step is being worked on right now – a way to access native JSON encoding and decoding from web pages. How it’ll be accessible is up to some debate (as having its naming conflict with an existing object would be a really bad thing). Regardless, there should be something within the browser by the time the Firefox 3 betas wrap-up.
(Via Ajaxian.)
Yahoo! OpenID Provider service now available as a public beta
Today, we are launching the public beta of the much-anticipated Yahoo! OpenID Provider service. This means that users with a Yahoo! account – all 248 million of them – will be able to sign in to any website that supports OpenID 2.0, the latest version of the OpenID specification.
In case you are curious, here are the key features of this release:
- Usability – Users will not have to understand the technical details of OpenID simply to use the technology. Thanks to features introduced in the OpenID 2.0 specification, users will not have to type their OpenID URL while signing in to websites. They can simply type yahoo.com in the OpenID textbox or, if the Relying Party website provides it, click a button that takes them to Yahoo!. By not requiring users to understand the meaning of an OpenID URL, we hope that more users will be able to overcome the initial hurdles of using this new echnology. For those of you who want to set up a custom URL, we will provide a way to do so, including the ability to use your Flickr photos page as your OpenID URL.
- User education – We have spent a great deal of time thinking about educating users on the proper use of OpenID and you will see some of these thoughts implemented throughout our service – whether it’s an explanation of the benefits of OpenID, our OpenID tour, or messaging on the safe use of OpenID at various locations.
- Anti-phishing measures – We suggest that users of the Yahoo! OpenID service set up and look for their Sign-in Seal to confirm that they are entering their password on a genuine Yahoo! page. A Sign-in Seal is a user-created image or a message that will only appear on genuine Yahoo! pages. We hope to continue working with the OpenID community to combat phishing and provide more secure experiences to users.
We are also actively working on non-US English versions of the service. It is already available for 17 countries and we expect to roll out even more international support in the very near future.
If you’d like to use the Yahoo! OpenID service, feel free to start at Plaxo, Jyte, Pibb, or any other OpenID 2.0-compliant website (this list is growing everyday). Alternatively, visit http://openid.yahoo.com to set up your account for OpenID access. We would love to hear your feedback!
We’d like to take this opportunity to thank the OpenID community for educating us over the past 1 year and helping us make this happen. In particular, we’d like to say “Thank you” to Bill Washburn, Brian Ellin, David Recordon, Dick Hardt, Johannes Ernst, Johnny Bufu, Joseph Smarr, Josh Hoyt, Kaliya Hamlin, Kevin Turner, Larry Drebes, Mike Graves, Scott Kveton, and Simon Willison.
Finally, we would not be here without the efforts of the Yahoo! Membership Platform team. Our special thanks go out to: Aanchal Gupta, Aaron Faupell, Anand Sankaralingam, Arockiasamy Mohanraj, Balaji Narayanan, Dhruv Manek, John Jawed, Michael Partridge, Naveen Agarwal, Nik Bonaddio, Rob Metzgar, Sabari Devadoss, Shrirang Ramachandra Kulkarni, Vish Shetty, Vivian Fernandez, Yu Wang. Thanks also to the all the other Yahoos that supported us in this effort.
We are obviously very excited about what this day means for our users, the OpenID technology, and the web in general. We are just getting
started and we hope to release more OpenID-enabled features in the future.
Shreyas Doshi and Allen Tom
Yahoo! Membership Platform team
Also: Jeremy Zawodny and Allen Tom sat down yesterday to briefly discuss OpenID at Yahoo. Here’s the video…
Deferreds
A quick review of the DojoX Cometd JavaScript client shows that the return value of init, subscribe and other methods is a dojo.Deferred object. So what is a Deferred and what makes it so powerful and flexible in a Comet client library?
A Deferred provides a standard way of doing asynchronous / non-blocking programming. Originally implemented in Twisted Python, it was first ported to JavaScript by the MochiKit developers, and subsequently ported to Dojo. A Deferred is simply a promise that a function will, at some point, have a result. This is convenient because developers can attach callback functions and error callbacks in a chain to process results. The results of one callback function are passed to the next callback function in the chain.
For example, inside the DojoX Cometd chat client, we see:
this.subscribe = function(channel, objOrFunc, funcName){
...
var _ds = this._deferredSubscribes;
_ds[channel] = new dojo.Deferred();
...
return this._deferredSubscribes[channel];
}
...
this._deliver = function(message){
...
switch(message.channel){
...
case "/meta/subscribe":
deferred = this._deferredSubscribes
[message.subscription];
if(!message.successful){
if(deferred){
deferred.errback(
new Error(message.error));
}
return;
}
dojox.cometd.subscribed(message.subscription, message);
if(deferred){
deferred.callback(true);
}
break;
...
}
As you can see, Deferreds provide a very concise mechanism for dealing with asynchronous message handling. DeferredList takes this a step further and allows you to synch multiple Deferreds:
dojo.DeferredList([deferred1, deferred2]).addCallback(bothCompleted);
deferred1 and deferred2 need not both be requests. For example, one could be an animation or drawing routine that is to finish at the same time as a request.
Some of the more advanced auto-wiring of chaining Deferreds can be very convenient. For example, adding a Deferred as a callback method for another Deferred will automatically trigger the added Deferred's callback method().wired up.
The full source for Dojo.Deferred is well-documented and explains in great detail how to get the most out of this powerful asynchronous programming pattern, making it very suitable for Comet and Ajax client development, as well as pubsub topic systems.
(Via Comet Daily.)
Library Agnostic LightBox
There are a lot of lightboxes out there. Most use specific libraries such as jQuery, Prototype or MooTools but few, if any, are completely library agnostic. This poses a challenge when you want to incorporate, say, a really cool lightbox from MooTools into a Prototype application.
Michael J. I. Jackson (no relation to the singer) wanted to address that and I think he’s done a stellar job with his newly released Shadowbox LightBox component:
A few weeks ago, I was looking for a Lightbox-like script that would allow me to display more than just pictures. In addition to static images, my client required the ability to display various types of movies including QuickTime and SWF. The only script that fit the bill was Lightwindow—a nice piece of work to be sure—but it required the Prototype + Scriptaculous combo and I was already using YUI.
Besides, I thought, it would be really great to have a full-featured media viewing application that was library agnostic. Then, if I need to use a different framework for some particular reason, I can easily switch.
Thus was born Shadowbox—a cross-browser, cross-platform, cleanly-coded and fully-documented media viewer application built entirely in JavaScript. It’s currently in beta testing phase, so please let me know on this post if you find any bugs or have problems with it.
The approach of making ShadowBox library agnostic and using an adapter architecture for plugging in different frameworks should really help to generate some buzz and acceptance of this plugin. Apart from that, the breadth of features and the smooth functionality make it very enticing.
(Via Ajaxian.)
Prototype 1.6.0.2: Bug fixes, performance improvements, and security
Today we’re releasing Prototype 1.6.0.2 to address several compatibility and performance issues and to protect against a potential security issue for developers using Prototype outside of a web browser environment.
Prototype 1.6.0.2 is a backwards-compatible, drop-in replacement recommended for all 1.6.0 users. We’ve fixed 28 bugs and made over a dozen improvements to the code base, including performance improvements for CSS selectors in Safari 3 and for the Element#up/#down/#next/#previous and Event#findElement methods in all browsers. We’re also now officially supporting the Opera browser, version 9.25 and higher. You can get the full scoop on all the changes in the 1.6.0.2 CHANGELOG.
Among the numerous bug fixes is a change to the way Ajax.Request handles automatic JavaScript response evaluation. Previous versions of Prototype relied on the browser’s XMLHttpRequest same-origin policy to ensure that response bodies with a content type of text/javascript were safe to evaluate. Alexey Feldgendler from Opera kindly alerted us to the possibility that certain non-browser environments (like Opera’s widget system) do not enforce the same-origin policy and as such may be subject to cross-domain script exploits. To combat this we’ve added an Ajax.Request#isSameOrigin method which returns true when a request is being made to the same domain, port, and protocol as the document. Furthermore, Prototype will no longer automatically evaulate JavaScript response bodies when this method returns false.
We’ve also backported the aforementioned security fix for those of you still using Prototype 1.5. Prototype 1.5.1.2 is a backwards-compatible, drop-in replacement recommended for all 1.5.1 and 1.5.1.1 users.
Download, report bugs, and get help
- Download Prototype 1.6.0.2
- Submit bug reports to Rails Trac
- Get Prototype help on the rails-spinoffs mailing list or #prototype IRC channel
- Interact with the Core Team on the prototype-core mailing list
As always, thanks to the core team and the many users who contributed bug reports and well-tested patches for this release.
A Study of Ajax Performance Issues
Coach Wei, of Nexaweb and Apache, has published a study of Ajax performance issues in browsers, and they won’t surprise you:
Obviously, we would like to see browser vendors take a serious look into the following issues and put them on their roadmap:
- In all major browsers, performance with Array and HTML DOM needs improvement in general.
- Browsers need to provide API support for Computed Box Model and Style;
- FireFox needs to improve performance of “eval”, object creation and “in” operation
- Internet Explorer needs to improve performance in general to be at least on par with other browsers. Beyond that, “String” manipulation on IE needs continued improvements;
- Safari: “pop” operation performance needs improvement
- Just-in-time (JIT) compiler: This maybe a bigger task than an incremental fix of some existing features, however, it is worthy of every penny. JIT will not only fix the String manipulation issue, it will enable JavaScript to truly shine in matching the performance of native applications. The amount of client side logic (aka, JavaScript code) needs to grow in order to accommodate the growth of application complexity, for which JavaScript runtime performance problem can be a major bottleneck.
Read the study to get the details on each item. It includes the results such as the DOM operation performance information:
(Via Ajaxian.)
Do you have a pretty date?
John Resig has created a little script to give you pretty dates that Web 2.0 know and love (thanks Rails):
-
-
prettyDate(“2008-01-28T20:24:17Z”) // => "2 hours ago"
-
prettyDate(“2008-01-27T22:24:17Z”) // => "Yesterday"
-
prettyDate(“2008-01-26T22:24:17Z”) // => "2 days ago"
-
prettyDate(“2008-01-14T22:24:17Z”) // => "2 weeks ago"
-
The library is short and sweet:
-
-
/*
-
* JavaScript Pretty Date
-
* Copyright (c) 2008 John Resig (jquery.com)
-
* Licensed under the MIT license.
-
*/
-
-
// Takes an ISO time and returns a string representing how
-
// long ago the date represents.
-
function prettyDate(time){
-
var date = new Date((time || “”).replace(/-/g,“/”).replace(/[TZ]/g,” “)),
-
diff = (((new Date()).getTime() – date.getTime()) / 1000),
-
day_diff = Math.floor(diff / 86400);
-
-
if ( isNaN(day_diff) || day_diff <0 || day_diff>= 31 )
-
return;
-
-
return day_diff == 0 && (
-
diff <60 && “just now” ||
-
diff <120 && “1 minute ago” ||
-
diff <3600 && Math.floor( diff / 60 ) + ” minutes ago” ||
-
diff <7200 && “1 hour ago” ||
-
diff <86400 && Math.floor( diff / 3600 ) + ” hours ago”) ||
-
day_diff == 1 && “Yesterday” ||
-
day_diff <7 && day_diff + ” days ago” ||
-
day_diff <31 && Math.ceil( day_diff / 7 ) + ” weeks ago”;
-
}
-
(Via Ajaxian.)
Adobe AIR is on Fire
Adobe AIR, the platform that lets you create desktop apps using web technologies, continues to garner attention. With Beta 3 just recently released and a host of companies coming out with new apps, AIR is building up a ton of steam just prior to it’s official v1.0 release.
First up, Adobe’s Kevion Hoyt gives us a rundown about the new AIR Introspector which is VERY similar to FireBug, but for AIR applications.
We’ve heard this request right from the start “Is there something like Firebug, that lets me monitor the assets in my application?” The answer to that question is now a resounding, YES! The AIR Introspector is designed to let you interact deeply with every aspect of your application.
Mind you that this is a BIG plus to AIR development which hasn’t benefited from having the ubiquitous FireBug to help during tough debugging sessions.
Some features included are:
- Point at a user interface element and be able to see and edit the markup and DOM properties.
- An interactive console that lets you access references, adjust values and execute JavaScript code.
- Lists links, images, CSS and JavaScript assets loaded into your application.
- Provides for viewing the original markup and the current markup.
- Viewer for XHR objects including their properties and headers.
- Search for matching text in the source code of your application.
Also, Aptana just updated the Studio IDE to support AIR Beta 3. While developing AIR in other editors is perfectly fine, Aptana really has done the best job of integrating support into their IDE making it substantially easier to build AIR apps. This is just pure speculation but I wouldn’t doubt that a big player, like Adobe, scoops up Aptana in 2008.
Nasdaq and American Cancer Society
ComputerWorld recently reported that the Nasdaq and American Cancer Society will be leveraging AIR for specific projects.
Nasdaq and the American Cancer Society are among several large organizations eyeing the Adobe runtime as a way to bridge the traditional gap between Web and desktop applications.
Using Adobe’s Flex and AIR, the Nasdaq created an application that can “can provide a replay of the quotes at the time of a trade — and associated prices on different markets — in seconds”.
The software runs on the desktop, relieving servers of a good deal of data-intensive processing, he noted. “We saw the ability to process the data halfway on our servers and have it in as small a package as possible. Then when someone requires a replay of the market, we send a small packet of data to desktop,” he said.
The American Cancer Society has been using AIR since early beta and has continued to build new apps regularly. Their recent initiative was a desktop application to assist users in determining when it was appropriate to schedule mammograms:
Another new Cancer Society application allows users to enter demographic information and receive suggestions about scheduling tests such as a mammogram, he said. The group hopes that providing such reminders on desktop systems will be more effective in prompting users about their treatment needs than forcing them to frequently visit a Web site, Pellegrini added.
They’re also creating a Flex/AIR-based portal for physicians that will allow the doctors to access Cancer Society’s information via the web or in an offline mode.
The offline synchronization capabilities of AIR are especially attractive to many companies as more and more employees are working remotely and may not have immediate access to the web. The inclusion of the SQLLite DB into the AIR runtime seems to have really piqued the interest of IT departments interested in providing the desktop experience without having to retrain their staff in traditional desktop tools such as C# or VB.Net.
Challenges Ahead
AIR is not in the clear though as very strong technologies from both Microsoft (SilverLight/.Net) and Mozilla (XULRunner) are serious challengers to the desktop space and could bite into AIR’s pie. The biggest advantage that AIR has, though, is Flash Player 9’s near 97% penetration rate. In addition, rumor has it that Adobe will issue an update to the Flash player that would include the AIR runtime making it a highly desirable target for building new applications. We’ll have to see if the rumor holds true.
For now, though, AIR is certainly showing a lot of promise and seems to have gotten past the “evaluation” stage. Once v1.0 is officially released (rumored to be sometime soon), the number of AIR applications will undoubtedly rise. I also envision an opportunity for developers to benefit financially from selling desktop applications that seamlessly tie into the web.
This should be interesting.
Update: Adobe’s Rob Christensen has sent me an update letting me know that Adobe has no plans at this time to bundle AIR with the Flash Player. One of the primary goals of the Flash Player is to keep the download size as small o that they can continue adding powerful features like h.264. Thanks for the update Rob.
(Via Ajaxian.)
Prototype 1.6.0.2 Cheat Sheet
Loyal Prototype user (and Scripteka maintainer) kangax has released a Prototype cheat sheet in coordination with our recent 1.6.0.2 release.

If in the past you’ve relied on Jonathan Snook’s cheat sheets for previous versions of Prototype, now there’s no excuse not to upgrade. Kangax’s version catalogs the full Prototype API, but marks in red those methods that have been deprecated in 1.6.
Friday afternoon isn’t the best time to announce a new release, so many of you may have missed the unveiling of Prototype 1.6.0.2 several days ago. It’s a bugfix and performance release that marks the beginning of our official support for Opera 9. Read the previous blog post for more details.
20080102-outaTiME, clubbers-vol.2
Today a new release of clubbers compilation comes, to play the record click here.
Track list:
- H2o ft Platnum – What’s It Gonna Be (Vandalism Remix)
- Dirty South – The End (Dirty South Mix)
- Morgan Page ft Lissie – The Longest Road (Discount Rhinos Remix)
- Booty Luv – Some Kinda Rush (Spencer and Hill Remix)
- The Last Days of Disco – What Does It Mean to U (Steve Mac Remix)
- Dave Armstrong – Love Has Gone (Wez Clarke Remix)
- Q45 & Amy B – Delete My Number (1992 Club Mix)
- Grant Nelson – Spellbound (Original Mix)
- Studio Apartment ft Ron Carroll – I’m in Love (Rasmus Faber Epic Remix)
- Yogi and Husky – It Feel’s Alright (Miguel Migs Petalpusher Rework)
- Ralf Gum Ft Monique Bingham – Kissing Strangers (Original Mix)

