Archive for the 'Javascript' Category
Posted by Shane O'Sullivan on 8 May, 2008
The Dojo Feature Explorer now has an Atom feed you can subscribe to to keep up with all the latest demos that have been added. So, point your browser at http://dojocampus.org/explorer/featureexplorer/latestDemos.xml and subscribe!
For all the Web 2.0 addicts out there, I’ve also added access to the list via SCRIPT IO. If you point your browser to http://dojocampus.org/explorer/featureexplorer/latestDemos.php, you will receive a file containing a JavaScript array of the last ten demos added to the feature explorer. By default, it will call the function dojocDemos, passing it the array. You can specify the callback function you want using the callback parameter. e.g.
http://dojocampus.org/explorer/featureexplorer/latestDemos.php?callback=myFunction
will call the myFunction JavaScript function. You can load this file, as I mentioned, using SCRIPT IO. This could be hard coded into your HTML page, e.g.:
<script type=”text/javascript” src=”http://dojocampus.org/explorer/featureexplorer/latestDemos/php?callback=myFunction”></script>
or loaded using dojo.io.script.
Posted in Ajax, Atom, Dojo, Javascript, Technical, json, open source | No Comments »
Posted by Shane O'Sullivan on 6 May, 2008
This is the second in series of posts on the work I’m doing to bring the Google Ajax APIs and Dojo Ajax Toolkit together. The first post was Google And Dojo, Sitting in a Tree, which you can read for some background.
I have submitted a new data store to the DojoX project, dojox.data.GoogleFeedStore, which makes it possible to access any RSS or Atom feed, anywhere, directly from your own web page. Simply pass the URL of the feed to the GoogleFeedStore, and it will return it to you using the dojo.data.Read API.
Example
var store = new dojox.data.GoogleFeedStore();
store.fetch({
query:{url:"http://shaneosullivan.wordpress.com/feed/"},
onComplete: function(items) {
dojo.forEach(items, "alert('Got feed entry with title ' + this.getValue(item, 'title'))", store);
},
count: 10
});
This will retrieve the first 10 entries in my blogs feed, and alert the title of each.
The huge advantage of this is that you no longer need any server side redirects to access RSS and Atom feeds from your own website. This Google service is the basis for Google Reader and iGoogle.
If you want to access an Atom feed from your own web server, you can also use the dojox.data.AtomReadStore that I wrote earlier. However, this is only useful if you have direct access to the Atom XML document using Ajax, and due to browser security issues, you can only load these documents from the web server hosting the web page. This new GoogleFeedStore removes that restriction, and has the added advantage that it also works with RSS.
Check out the demo page to get a feel for it (available in the May 6th nightlies), and there should be an example up on the Dojo Feature Explorer quite soon too.
As before, a big thanks to Google for providing such a cool service.
Posted in Ajax, Dojo, Feeds, Google, Javascript, Technical, dojo.data, dojox, dojox.data, json, open source | 4 Comments »
Posted by Shane O'Sullivan on 1 May, 2008
I’ve submitted a bunch of new data stores to the Dojo Ajax Toolkit that make it simple to search Google directly from your own site (ticket here).
Update: I’ve also submitted a store to read any Atom or RSS feed, anywhere, without any server redirects. See Google And Dojo, F.E.E.D.I.N.G
This is different from putting a search box on your site and redirecting to Google. With the new dojox.data.GoogleSearchStore family of data stores, you can retrieve google search results in JSON format, and display them on your site directly.
Pause a second…. let it sink in…..
There are no cross domain issues, and no server side component is required. It uses the dojo.io.script transport to access the Google Ajax API service. Just stick the following on your page:
<div dojoType=”dojox.data.GoogleWebSearchStore” jsID=”googleStore”></div>
and you have Google’s millions of servers at your fingertips.
The following data stores are available:
- GoogleWebSearchStore - does a standard web search.
- GoogleBlogSearchStore - searches blogs. A future enhancement I will be writing will be to write a data store that accesses Google’s extremely cool Ajax Feed API, which provides access to any ATOM feed, anywhere, in JSON. It’ll be possible to do a full web search of all blogs for certain topics, then using the feed store to pull down that complete feed .
- GoogleLocalSearchStore - searches the Google Local service to find places, businesses etc.
- GoogleVideoSearchStore - Does what it says on the tin, searches for videos.
- GoogleNewsSearchStore - Finds news stories…. noticing a pattern yet?
- GoogleBookSearchStore - Um, finds books..
- GoogleImageSearchStore - Finds images. This provides both a thumbnail and full sized version, similar to the FlickrRestStore already provided by Dojo.
The potential applications are more or less infinite. Demos included in the check-in show how to integrate this with the extremely cool dojox.dtl templating engine to display the results in a number of different ways, as well as how to feed the results into the Dojo Grid, Gallery and SlideShow.
This code is included in the nightly checkouts of Dojo, and not in v1.1. To get it, either check it out from source control, or get it from http://archive.dojotoolkit.org/nightly/.
Have a look at the simplistic demo of it in action at http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/data/demos/demo_GoogleSearchStore.html (available from the May 1st nightlies).
A big thank you to Google for making this service available. Now go play!
P.S. Stay tuned for the Yahoo variant, coming soon!
Posted in Ajax, Atom, Dojo, Javascript, Technical, dojo.data, dojox, json, open source | 10 Comments »
Posted by Shane O'Sullivan on 3 April, 2008
A great new demo engine has just been released for the Dojo Toolkit. Check it out at http://dojocampus.org/explorer/. It is based on the initial attempt at a demo engine I wrote a few months ago, but has since been updated with new demos, and made infinitely more sexy by css/theme master Nikolai Onken.

The features include:
- Demos for all three Dojo projects - Dojo (the base toolkit), Dijit (widgets) and DojoX (all that is newest and coolest) .
- Source views for all demos. Not only do we show what Dojo can do, we show you how to do it! The source views also benefit from the very cool dojox.highlight project, which provides client side syntax highlighting.
- Addressability - you can link directly to a demo, as I did with the dojox.highlight link above.
- Search feature - a combo box that you can use to quickly find a demo on any subject. For example, type “image” into the box, and you’ll be shown a list of all demos to do with displaying images, such as dojox.image.Gallery, dojox.image.SlideShow etc.
- Cool animated menus - totally aesthetic I know, but a very pretty addition by Peter Higgins. The menus separate the three projects, providing easier, clearer navigation.
- Link hierarchies - each set of demos can have links attached to it, for example to extra tutorials or documentation. If you click a parent of that demo, you are shown all links of all children of that section. For example, click on the DojoX link on the top of the page, and you’ll be presented with a list of all links to all DojoX projects.
- Browser Back Button management. Using the dojo.back package, you can navigate back and forward through the application using the browser’s back and forward buttons.
The demo engine is hosted on the extremely cool Dojo Campus website, which is a new learning resource for all things Dojo. It contains videos, tutorials and much more.
This version of the demo engine has many many examples in it. However, it is only the beginning, and there is a lot of room to add more content. The next step is to open the development process for community submissions of all the cool things people have done with Dojo. We will be making available the demo engine on Subversion, and writing development and submission processes to make it as easy as possible for people to contribute.
This is gonna be big!
Update: see http://ajaxian.com/archives/dojo-mini-and-the-feature-explorer for the Ajaxian post.
Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt
Posted in Ajax, Demo Engine, Dojo, Image Gallery, Javascript, Technical, demo, dijit, django, dojo.charting, dojo.data, dojo.event, dojo.image, dojo.query, dojox, dojox.data, dojox.image, json, open source | 10 Comments »
Posted by Shane O'Sullivan on 28 March, 2008
The latest and greatest release of the Dojo Ajax Toolkit has just hit the presses, and she’s looking good. As Alex mentioned, the number of cool features in Dojo can be difficult to keep up with, so I’ll just list some of the things I’ve either written for Dojo, helped along, or just been damn impressed by in this release:
Dojo Datastores
The number of useful data stores for Dojo just keeps growing and growing, under the watchful eye of Jared. For release 1.1, I submitted a data store to read Atom XML documents, dojox.data.AtomReadStore. See more about this at http://shaneosullivan.wordpress.com/2008/02/20/new-atom-data-store-for-dojo/.
FisheyeLite
Peter Higgins submitted an amazingly simple, but oh-so-cool widget called dojox.widget.FisheyeLite. Rather than act like a ‘true’ Fisheye widget, which would generally only work on images (á la OS X), this widget can apply cool Fisheye-like behaviors to just about anything - text, divs, spans, you name it. Check out the test page for some cool examples, or see my personal website for an example of how I used it to spruce up my site menu.
Django Template Languate - dojox.dtl
The Django Template Language is an amazingly powerful templating language, with which you can turn your JavaScript data into HTML. While this was originally designed to be a server side templating solution, Neil Roberts has done a brilliant job of converting it over to work in the browser. While I though I’d had an original idea when I pitched the idea to him that it’d be cool to integrate Dojo data stores directly into DTL, Alex already had the whole thing implemented and about to check it in. Typical
I’ve written up a tutorial on how to integrate DTL with Dojo data stores, specifically the AtomReadStore I wrote, at http://shaneosullivan.wordpress.com/2008/03/03/writing-a-django-template-widget-with-dojo-data-stores/.
Functional Programming
This enables you perform many operations on data using just a single function call. Once of the cool things it provides is the ability to specify a function as a simple string, drastically reducing the complexity and size of your own code. Eugene Lazutkin wrote a great blog post about this, which is well worth a read. I wrote a follow up post, as a quick reference to some of the cool things you can do with this feature. Some of this was available in 1.0, but I’ve just discovered it, so here you go!
Dojo Campus
Peter Higgins, Nikolai Onken and myself have been working on a new learning resource for Dojo developers, called Dojo Campus. It provides a lot of learning materials, including videos, tutorials for beginners and more advanced programmers, and much more. We also have a still-under-wraps-but-soon-to-be-release demo engine that has loads of easy to use runtime examples of things to make and do with Dojo. I blogged about a very early version of it at http://shaneosullivan.wordpress.com/2008/01/07/dojo-demo-engine-update/, but it’s come a long way since then. Keep you eyes peeled for it’s release. Any day now…..
And finally….
A very sexy Calendar widget I’ve written got submitted just a bit too late to make in into 1.1 (read: the day before release), but will be in the nightlies soon, and will make it into 1.2. See the blog post about it at http://shaneosullivan.wordpress.com/2008/03/24/sexy-new-calendar-widget-for-dojo/.
This is nowhere near a comprehensive list of course, just the bits I’ve been fiddling with over the last few months:
- See Dylan’s post for some more info.
- Get the release notes here.
- See the Ajaxian post here.
- See Alex Russell’s (Dojo project lead) post here.
So go forth and explore, it’s good healthy nerd-fun! Share this post:
digg it|kick it|Email it|bookmark it|reddit|liveIt
Posted in Ajax, Alex Russell, Atom, Date Picker, Demo Engine, Dojo, Javascript, Technical, demo, django, dojo.data, dojox.data, json, open source, widget | No Comments »
Posted by Shane O'Sullivan on 24 March, 2008
I’ve submitted a sexy new Calendar widget to the Dojo Toolkit, called dojox.widget.Calendar. Check out a test page for it at http://www.skynet.ie/~sos/js/demo/dojo/dojox/widget/tests/test_Calendar.html. The ticket tracking it is at http://trac.dojotoolkit.org/ticket/6297.
The features of this calendar widget are:
- Day view - the standard view, showing all the days in a month
- Month view - lists the twelve months of the year.
- Year view - lists all the years that can be chosen.
- Cool animations between these views.
- Cool animations when moving from month to month, and from year to year.
- Cool animations when moving the mouse over the widget, courtesy of the dojox.widget.FisheyeLite widget. (tired of cool animations yet? Nah, me neither)
The daily, monthly and yearly views of the Calendar

I was inspired to write it after seeing the very cool Calendar widget in the AjaxControl Toolkit, a .NET Ajax framework, which made me think “I wonder how long this would take to write with Dojo?“, taking into account the obvious: not a single line of code could be copied from the original.
The answer turned out to be about 3 hours or so, since Dojo already provided the majority of what I needed.
- All the Date-related heavy lifting is done with dijit._Calendar, the existing Dojo calendar widget. This also handles the majority of the localisation issues.
- Most of the animations are done using the dojo.animateProperty function.
- Generating the HTML of the widget is mostly taken care of by the standard Dijit templating system.
What remained to do was changing the exiting dijit._Calendar HTML template to give a month and year view, and fiddling with CSS to get it looking right. A textbox popup widget was also submitted to integrate the Calendar with a text input field, called dojox.form.DateTextBox;
Hopefully this will make it’s way into the DojoX project fairly soon, and be available for general use.
Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt
Posted in Ajax, Calendar, Date Picker, Dojo, Javascript, Technical, dijit, dojox, open source | 4 Comments »
Posted by Shane O'Sullivan on 3 March, 2008
One of the very cool recent additions to the Dojo toolkit is support for the Django Template engine. It is essentially a very advanced browser based templating engine, that enables you to use things like FOR loops, IF statements and much more directly in a HTML template. Or, as the author puts it:
The Django Template Language is one part of Django, a “high-level Python Web framework that encourages rapid development and clean, pragmatic design.
This blog post is an in depth tutorial on working with DTL, Atom XML and Dojo data stores. To see the final working version, have a look here, or get the code from here. Extract the code at the same level as Dojo, and open the demoAtomDTL.html file. Note that you need either the nightly Dojo code, or v1.1 or later for this to work.
Simple Example
As a very simple example, you could write a single template, such as
<ul>
<!--{% for item in items %}-->
<li value="{{item.value}}">{{item.text}}</li>
<!--{% endfor %}-->
</ul>
Then, you populate the template with some JSON data, e.g.
{
items:[
{value:1,text:"Choice 1"},
{value:2,text:"Choice 2"},
{value:3,text:"Choice 3"}
]
}
and it generates the following HTML.
<ul>
<li value="1">Choice 1</li>
<li value="2">Choice 2</li>
<li value="3">Choice 13</li>
</ul>
Writing A Widget And Template To Work With Atom XML
The example above is simplistic, though still very useful of course. However it is possible to do much more interesting things with DTL. A recent enhancement to the code base means that a template can now be built using data from a dojo.data repository, rather than a simple JSON object. This means that you can have a single template that can be used with data from many different data sources (see here for an ItemFileReadStore and here for a Flickr data store example).
This post shows how to write a templated widget that uses a Dojo data store I have written for reading Atom XML data (which has been committed to the Dojox project), and transforming it using DTL into a nice fancy HTML widget, complete with visual effects. See http://www.skynet.ie/~sos/blog.php to see the final result. Do a “View Source” on that page to see how simple it is to include it on a page.

Writing the Template
Firstly, the structure of the HTML to be produced must be decided. For this example, I’ll just create a series of DIV elements that contain a header for the title, and a body for the text. The body will also contain another DIV to list all the tags (or categories in Atom-speak). So, a single entry will end up looking like:
<div class="entry">
<div class="entryTitle">This is an entry title</div>
<div class="entrySummary">
This is some summary text
<div>
Tags: <a href="http://shaneosullivan.wordpress.com/category/ajax">Ajax</a>
</div>
</div>
</div>
A template for this looks as follows:
<!--{% load dojox.dtl.contrib.html %}-->
<div id="{{rootId}}" >
<!--{% for item in items %}-->
<div class="entry">
<div class="title"><!--{{item.title.text}}--></div>
<div class="summary">
<!--{% if item.summary.type == "html" %}-->
<!--{% html item.summary.text %}-->
<!--{% else %}-->
<!--{{ item.summary.text }}-->
<!--{% endif %}-->
<div>
<!--{% if item.category %}-->
Tags:
<!--{% for cat in item.categorys %}-->
<a href="{{cat.scheme}}/category/{{cat.term}}"> <!--{{cat.term}}--> </a>
<!--{% endfor %}-->
<!--{% endif %}-->
</div>
</div>
</div>
<!--{% endfor %}-->
Break it down!
Ok, so let’s have a look at this.
Read the rest of this entry »
Posted in Ajax, Dojo, Feeds, Flickr, Javascript, Technical, dijit, dojox, dojox.data, json, open source | 5 Comments »
Posted by Shane O'Sullivan on 20 February, 2008
I’ve just submitted a patch to the DojoX project for a dojo.data data store that can read Atom XML documents. It’s relatively simple for the moment, but is capable of taking an XML document that conforms to the Atom spec, and returning the entries using the dojo.data.Read API.
Update: this has now been committed to the DojoX project.
This arose out a desire to rewrite the page on my personal website that mirrors this blog. At time of writing, that has a strong dependency on PHP to query my blog for the Atom feed, parse the feed, and output it using a server side HTML template.
This is of course be easily achievable on the browser also, except for the fetching of the XML document from the remote website which the server would still have to do. Of course, if the Atom URL is on the same server as the page, even this dependency could be removed, and all the work, from the fetching, parsing and templating, could be done on the browser.
However, implementing this as a Dojo data store has many advantages, the primary one being that I get to play with integrating a Dojo data store with the very very cool Django templating language package in DojoX, dojox.dtl. Alex recently checked in a patch to dojox.dtl that enables the use of dojo.data stores directly in templates, so I can’t wait to get this checked in (once any issues Jared has with it are satisfied) and get going on my site!
Share this post:digg it|kick it|Email it|bookmark it|reddit|liveIt
Posted in Ajax, Alex Russell, Atom, Blogs, Dojo, Feeds, Javascript, Technical, dojo.data, dojox.data, json, open source | 2 Comments »