December 28th, 2008 by Aaron N.
Ian Collins is apparently hooked on MooTools because he sure has been writing a whole heckuva lot of it. He emailed me a few days back about his site that is all dynamically built off Twitter, Flickr, and other sources using JsonP to fetch all the data. The entire experience is built in JavaScript. Looking at the source of his site you find this lovely little easter egg:
<body>
< -- I win at SEO -->
</body>
The source of the site itself is all cleanly written MooTools classes, reminding me of my thoughts on programming to patterns.
He’s also released through github a project structure based on MooTools and Clientcide tools and conventions. This is basically how I organize all the Clientcide code along with both test frameworks (Ian includes ScrewUnit – while Clientcide and MooTools use JSSpec, but they both do the same thing – and my Unit Test Framework). Read the rest of this entry »
Posted in 3rd Party Libraries, Examples, Organizing Code, Server-side Integration | 3 Comments »
December 18th, 2008 by Aaron N.
For those of you unfamiliar with JsonP, it’s the process of using script injection to fetch data across domains (where Ajax requests prevent this access). You inject a script tag into your document with the url of a web service and instruct that web service to send JSON data back wrapped in a function name you specify in the url. Then you have the function defined in your document waiting for that script to load and call your function, passing the response.
You can see it in action here using my JsonP class for MooTools.
Today I got an email from a fellow by the name of Alan who has released jsonptunnel – CGI and FastCGI scripts that receive JSONP requests (which, do to their script call methodology are always GET requests) and turn them into POST requests. Tres cool.
In order to POST to an off site web service, a GET URL is formatted and fetched that looks like this:
?extURL=http://dipert.org/alan/calc.php&extMethod=POST&num1=10….
This tells the CGI to fetch the specified URL using the specified HTTP verb and pass the specified variables.
Posted in Server-side Integration | Comments Off
December 4th, 2008 by Aaron N.
Digging around on Nathan White’s blog, I found a link to some MooTools 1.2 plugins over on Chris Esler’s blog. Then I found this little gem.
Well I’ve been rather obsessed lately with getting mootools running in a server-side environment. I’ve had some minimal experience with Helma, but I decided to try and build my own. At this point its rather simple, but I have managed to initiate the jetty webserver with mootools and to write java handlers in javascript (again with mootools) to handle my requests. I looked at a few internet posts about doing your own javascript web frameworks, but most I had a hard time getting to work on my local environment as well as my server environment. So after about a month of diving into Rhino documentation and Jetty documentation I’ve got something fairly predictable working.
Nifty.
Posted in 'Industry' News, MooTools, Server-side Integration | Comments Off
January 24th, 2008 by Aaron N.
I was helping someone today with their javascript and they asked me about how and when I manage errors in the classes and functions that I write. I wrote him back an email which I think actually could be useful to others, so here it is.
There are three types of error handling that I use:
- Graceful: if possible, just ignore the error and continue with some default state or without a meaningful value
- Debug: throw a warning to the dbug.log method but continue otherwise
- Break: Either explicitly throw an error or (more often) just let the error that is thrown at runtime be thrown
Read the rest of this entry »
Posted in Optimization, Server-side Integration, Uncategorized | 1 Comment »
November 19th, 2007 by Aaron N.
via Ajaxian:
Addison-Wesley and Prentice Hall are putting on a conference dedicated to GWT on December 3-6 in San Francisco.
Much more detail in the blog post there.
Posted in 'Industry' News, Server-side Integration | Comments Off
October 24th, 2007 by Aaron N.
The CNET JS code includes references to various assets – images and a few css files and at least one flash (swf) file. I include references in the javascript so that these things “just work” when you use them.
First and foremost, our libraries are designed for us to develop with, and making that process easy is our main concern. The problem is when you want to use these scripts somewhere other than CNET (or for local development).
Well, now you can. Just download the assets here:
http://code.google.com/p/cnetjavascript/downloads/list
Then use http://cnetjavascript.googlecode.com/svn/trunk/setAssetHref.js to set the location of the assets. Voila.
Posted in CNET JS Standards, Server-side Integration | Comments Off
October 15th, 2007 by Aaron N.
Hey gang,
Two new classes in the CNET libraries today.
CNETAPI.js
The first, CNETAPI, is probably not going to be very interesting to those of you reading this who don’t work at CNET. Basically, this class makes it super-duper easy to get stuff out of our REST API. For example:
//you have to do this only once on your page
//this is my dev key; get your own!
new CNETAPI(19926949750937665684988687810562);
//now our request:
new CNETAPI.TechProduct(32069546).chain(function(){
dbug.log("got the Ipod, here's the data: ", this.data);
alert(this.data.Name + ": " + this.data.EditorsRating.$);
});
Pretty snazzy, eh? Props go to Hunter Brown who wrote the guts of this class. I (Aaron) added some flare. More details and examples in the wikitorial.
ObjectBrowser.js
I’m working on some CMS tools for selecting options out of a tree (think genres/ontology) and I needed a tree browser. So I wrote a generic one that can be used to explore just about any kind of javascript object. Rather than paste in a lot of detail here, I’ll just point you towards the wikitorial.
Posted in CNET API, Server-side Integration, Widgets | Comments Off
April 26th, 2007 by Aaron N.
We’re working on an internal build system here at CNET that is a mixture of things like Mootools download builder and Dean Edward’s /packer/ so that we can quickly include just the javascript that’s needed on a page.
Today’s post at Ajaxian shows that we’re not the only ones working on such a thing. Our solution though will likely be very specific to our application development, so I don’t know if we’ll be able to release it. In the comments of the post below, I also found a link to packtag, which seems to be an open source Java version of this very same functionality.
Via ajaxian:
We love to play with the plumbing don’t we. jscsscomp is the latest compressor that uses Nicolas Martin PHP version of the Dean Edwards JavaScript Compressor.
With a swish of mod_rewrite:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.)(js|css)$ jscsscomp/jscsscomp.php?q=$1$2 [L,NC]
you can get your JavaScript like this:
<script src = "/jscsscomp/yahoo.js, dom.js, event.js, effects/dragdrop.js, slider.js"></script>
Posted in Optimization, Server-side Integration, Tools | Comments Off
January 22nd, 2007 by Aaron N.
via Ajaxian.
Ben Alex of Interface 21 has written a detailed post on Java to JavaScript compilation.
The article discusses some of the choices out there (GWT, OpenLaszlo) and goes into an open source alternative called Java2Script Pacemaker.
Spring integration is shown and available for download and it concludes:
J2S promises some attractive benefits for projects that require JavaScript compilation or a web browser implementation of SWT. It also interoperates successfully with a Spring backend. J2S’ deliberate choice to leverage proven existing technologies such as AST and SWT make it a good example of reusing existing code and developer skills, in turn lowering adoption barriers and the prospect of material API change. If you consider yourself an early adopter, SWT devotee, or need a client-centric, web-based user interface that is built upon the mature SWT UI framework, it is definitely worth taking a closer look at J2S.
Does SWT support do it for you?
Posted in Server-side Integration | Comments Off
August 22nd, 2006 by Aaron N.
Now, what was I just saying?
via Ajaxian:
Cody Swann was working on a web application that was using the Dynamic Script Pattern, which Dojo has excellent support for, but Prototype didn’t.
Cody then extended Prototype to support ScriptSrcTransport similarly to how Dojo does it.
The code below support the Simple, Polling and JSONP and JSON Callbacks described in the Dojo book.
Posted in Code Snippets, Examples, Optimization, Organizing Code, Prototype, Server-side Integration | Comments Off