Facebook releases JavaScript Client Library

View original post found on Ajaxian » Front Page authored by Dion Almaer

Wei Zhu seems to be cooking with gas recently, and has released the JavaScript Client Library for Facebook API, which is a client side JavaScript library that mimics the other language client libraries (PHP, Python, Java, Ruby, etc):

An application that uses this client library should be registered as an iframe type. This applies to either iframe Facebook apps that users access through the Facebook web site or apps that users access directly on the app’s own web sites.

The solution uses a cross domain receiver:

PLAIN TEXT
HTML:

  1.  
  2. <html xmlns=“http://www.w3.org/1999/xhtml”>
  3.     <title>cross domain receiver page</title>
  4. </head>
  5. <body style=“background-color:Green;”>
  6.     <script src=“http://static.ak.facebook.com/js/api_lib/XdCommReceiver.debug.js” type=“text/javascript”></script>
  7.     <script type=“text/javascript”>
  8.         FB_ReceiverApp$main();
  9.     </script>
  10. </body>
  11. </html>
  12.  

Then, with a few script src’s you can talk to Facebook:

PLAIN TEXT
JAVASCRIPT:

  1.  
  2. // Create an ApiClient object, passing app’s api key and
  3. // a site relative url to xd_receiver.htm
  4. var api = new FB.ApiClient('<insert_your_app_key_here', ‘/xd_receiver.htm’, null);
  5.        
  6. // require user to login
  7. api.requireLogin(function(exception) {
  8.     window.alert(“Current user id is “ + api.get_session().uid);
  9.  
  10.     // Get friends list 
  11.     api.friends_get(function(result, exception) {
  12.       Debug.dump(result, ‘friendsResult from non-batch execution ‘); 
  13.     });       
  14. });
  15.  

It is good to see a JavaScript API like this. Now you can stay in JavaScript land and write code that works with OpenSocial, Facebook, and more. NOTE: If you live in FBML? No cigar.

JsonSQL: JSON parser, SQL style

View original post found on Ajaxian » Front Page authored by Dion Almaer

Trent Richardson has released JsonSQL, a JavaScript library that allows you to muck around with JSON as though it is a datastore:

The API

PLAIN TEXT
JAVASCRIPT:

  1.  
  2. jsonsql.query(“select * from json.channel.items order by title desc”, json);
  3.  
  4. jsonsql.query(“select title,url from json.channel.items where (category==’javascript’ || category==’vista’) order by title,category asc limit 3″, json);
  5.  

Usage

  • Only Select statements are supported
  • The requested fields may be a “*” or a list of fields. “*” is likely faster in most cases.
  • When typing lists “select field1,field2,field3″ or “limit 5,10 do not use spaces.
  • When using the “where” clause enclose all conditions with one set of parenthesis “where (category==’The Category’ || category==’Other Category’)”.
  • The where clause is a javascript condition, not sql. It should use the scope emplied by “from”. Javascript functions may be used here as well as javascript operators.
  • The from clause should establish the scope you would like returned. It should start with “json” and use the dot notation: “json.channel.items” and should point to an array within the object.
  • The order by option can accept a list but will only order by the first field at this time(asc,desc,ascnum,descnum).

Protected: Highslide JS: JavaScript Thumbnail Viewer

View original post found on Ajaxian » Front Page authored by Dion Almaer

This post is password protected. To view it please enter your password below:

Password:

jQuery 1.2.2 Released

View original post found on Ajaxian » Front Page authored by Dion Almaer

jQuery has a new release, 1.2.2, which is a bug fix release and more. This release comes on the 2nd birthday of jQuery:

I remember doing the first release at BarCamp NYC (combined with the mention of two other projects of mine that fizzled: Feed Pile and Idea Shrub). While I had released a bunch of open source code in the past, this was the first one that I put some serious effort into getting publicity. Luckily it made it onto del.icio.us/popular, digg – and the rest is history.

Amusingly, the entire chain of popularity was due to the fact that I made a troll-y comment on a Prototype blog post (when they announced their new selector feature) and it was discovered and re-blogged by Ben Nolan (creator of the Behaviour library for Prototype). From there it hit the Rails community and was launched onto del.icio.us, digg, etc.

The major changes are:

  • 300% Speed Improvements to $(DOMElement)
  • .ready() Overhaul: Uses Diego Perini’s non-document.write() technique, now wait for CSS to be ready, can now watch for the document ready event via the traditional .bind()
  • .bind(”mouseenter”) / .bind(”mouseleave”)
  • Complex :not()
  • Accepts Headers
  • Event API: jQuery.event.special setup teardown handler

You can download the latest release (minified).

WireIt: Yahoo! Pipes Canvas Wiring API

View original post found on Ajaxian » Front Page authored by Dion Almaer

Eric Abouaf has released WireIt, a library that answers the though: “wow, I wish there was an API that did the UI bits that Yahoo! Pipes does.”

WireIt uses canvas, excanvas for IE, and YUI to get the job done. Take a look at the docs to see how it works.

Here is the code for simple terminals:

PLAIN TEXT
JAVASCRIPT:

  1.  
  2. var bl = YAHOO.util.Dom.get(‘blockLeft’);
  3. var br = YAHOO.util.Dom.get(‘blockRight’);
  4. var bt = YAHOO.util.Dom.get(‘blockTop’);
  5. var bb = YAHOO.util.Dom.get(‘blockBottom’);
  6.        
  7. for( var i = 0 ; i <7 ; i++) {
  8.         new WireIt.Terminal(bl, {direction: [1,0], offsetPosition:[0,i*50] });
  9.         new WireIt.Terminal(br, {direction: [-1,0], offsetPosition:[0,i*50] });
  10.         new WireIt.Terminal(bt, {direction: [0,1], offsetPosition:[i*50,0] });
  11.         new WireIt.Terminal(bb, {direction: [0,-1], offsetPosition:[i*50,0] });
  12. }
  13.  

And there is even a fun game to check out:

Planar

Ajax Cross Domain Script

View original post found on Ajaxian » Front Page authored by Dion Almaer

Bart Van der Donck has released his script to do Ajax Cross Domain scripting. You download the ACD.js script and then you can do things like this hello world:

PLAIN TEXT
HTML:

  1.  
  2. <script type=“text/javascript” src=“http://www.ajax-cross-domain.com/cgi-bin/ACD/ACD.js?uri=(http://216.92.176.52/?name=john)”></script>
  3. <script type=“text/javascript”>alert(ACD.responseText);</script>
  4.  

Here is how it works:

I love how the learning curve has been defined for you to Bart :)

Making the OpenSocial API feel more at home

View original post found on Ajaxian » Front Page authored by Dion Almaer

Chris Chabot has been doing a lot of experimentation with the new OpenSocial APIs. He has written up his experience and created two prototype wrappers.

The first short article has some general information and background.

The second article includes the first library you can tell to load (owner, viewer, ownerFriends and/or
viewerFriends) information, and presents this information in an uniform way (instead of having to do different type of calls for different information fields) and with proper consistent error handling. With it you can very easily create your first OpenSocial container application in a friendly prototype style environment. You can take a direct look at the library itself.

The third article contains a Ajax.Request implementation, since Prototype’s version won’t work well or even at all in the cross domain environment of open social containers, it allows you to re-use your current Prototype based programs by trying to mimic Prototype’s Ajax call as well as possible given the constraints of the situation. Under the hood, _IG_FetchContent is used to talk back to the server.

It is good to see people take the raw APIs and make them feel more like their library of choice.

JSLoader: On Demand JavaScript Libraries

View original post found on Ajaxian » Front Page authored by Dion Almaer

Dov B. Katz has released JSLoader, his open source on-demand JavaScript library. He explained to us:

It provides a methodology for organizing JS libraries, and programmatically loading them by simply “asking” for them. Example code: JSLoader.load(“ria”,”ext”,”2.0-beta1”);

I developed it as a mechanism to provide hosted Ajax libraries within a large enterprise (zero install, we maintain the latest releases) and it has been very successful. Furthermore, because no install is needed, I have leveraged TWiki to create a rapid prototyping environment, which has led to widespread adoption in the enterprise.

Ultimately, it’s just dynamically writing script and link tags onto the page… Not rocket science, but it works well, and it’s proven its value in an enterprise environment.

Why JSLoader?

  • First of all, it’s a zero-install solution. The goal is to eventually deploy this style of loading and file organization on a “hosted toolkit” system and allow websites to leverage the distribution of new toolkits without having to figure out how to install them.
  • Second, because multiple sites will share this code the browser and proxy caches will help make things more efficent
  • Finally, the maintainability of toolkits is minimized as content needs to be distributed only once, instead of having each user download a private copy

You can see some demos such as PlotKit.

Dov is going to be at The Ajax Experience this week in Boston. He is keen to meet you to discuss it!

Re-inventing XMLHttpRequest: Cross-browser implementation with sniffing capabilities

View original post found on Ajaxian » Front Page authored by Dion Almaer

Sergey Ilinsky has written up an article on an XMLHttpRequest implementation wrapper that provides an equal XHR playground across the various browsers.

If you use the wrapper you can fix things like:

As part of his work Sergey compared the browser implementations:

XMLHttpRequest Appendix

And has made his code available for download.