SOS

Shane O'Sullivan's technical blog… really ties the room together

Archive for September, 2008

Dojo based Inflation calculator

Posted by Shane O'Sullivan on September 29, 2008

A cool project based on the Dojo Ajax toolkit has just gone live.  The Cost of Living Calculator from KBC Bank and The Sunday Independant (in Ireland) newspaper enables you (especially Irish people :-)) to calculate their own personal inflation rate.  This is the rate of inflation as it applies to you personally, based on what you spend your money on, rather than the inflation rate average for the entire country.

It uses many features of the Dojo toolkit version 0.4.2, including tab containers, spinner widgets and charting.

Give it a go at http://www.kbc.ie/colcalc/calc

Click the Tutorial tab for instructions on how to use it, but it’s not complicated at all.

Posted in Ajax, calculator, Dojo, inflation, Javascript | Leave a Comment »

Chofter.com UI Overhaul

Posted by Shane O'Sullivan on September 28, 2008

I’ve completely overhauled the look and feel of Chofter.com, my next-gen search portal build using the Dojo Ajax Toolkit.  It’s now much more user friendly, prettier etc.  I’ve also fixed a number of small bugs.

Read the official blog post about it at http://chofter.com/blog/?p=26, or even better, try out Chofter.com for yourself!  It rocks, if I do say so myself (and I do :-) )

Ajaxian seemed to like it too.

Some pics of the new look

Posted in Ajax, chofter, Dojo, dojo.data, Javascript | 2 Comments »

Quick Django Tip – Modulus

Posted by Shane O'Sullivan on September 27, 2008

I was fiddling around with Dojo‘s Django Templating language (amazingly cool bit of tech of course), and got a bit stuck trying to do something very simple: modulus

All I wanted to do was stripe a list of elements by applying a different class based on whether a row was odd or even. It turns out the reason the answer didn’t really pop up in searches was because, in Django land, it is called divisibleby

So, if you are using a for loop in Django, to check if
(current loop index % 2) == 0
you can use
{{forloop.counter0|divisibleby:2}}

which returns either true or false.

Posted in django, dojox, Javascript, Technical, templating | 9 Comments »

More Offline Goodness With Dojo

Posted by Shane O'Sullivan on September 23, 2008

Kris Zyp from SitePen has posted an article about the Dojo Ajax Toolkit‘s latest addition to it’s Offline Web capabilities, OfflineRest. Check it out at http://www.sitepen.com/blog/2008/09/23/effortless-offline-with-offlinerest.

The idea is brilliant – if you send your data to the user using the JsonRestStore, you can now add an amazingly simple offline capabilty to your website with two lines of code (more or less).

This rocks.

There’s also an interview with Kris over at Ajaxian – http://ajaxian.com/archives/audible-ajax-episode-30-interview-with-kris-zyp

Posted in Ajax, Dojo, dojo.data, dojox.data, json, offline, open source | Leave a Comment »

Setting the default locale in Dojo using PHP

Posted by Shane O'Sullivan on September 13, 2008

When writing locale aware JavaScript for a browser environment,  you only have access to the locale that the browser used upon installation.  If the user changes their preferred locale, a JavaScript application has no way of detecting it.  See the Dojo documentation for more details on this at http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/i18n/specifying-locale

However, the list of accepted languages are sent to the web server in the request headers.  It is also possible to instruct Dojo as to which locale to use.  Below is an example of how to do this in PHP

<?php
 // Get the array of request headers
 $h = getallheaders();
 // Retrieve the 'Accept-Language' header, a comma separated list
 $langs  = $h['Accept-Language'];
 // Parse the first language
 $locale=strtok($langs,",");
 if(strlen($locale) < 1) {
  // Set a default language if you like
  $locale = "en";
 }else {
  // Make sure that the optional 'q' parameter is not included
  $locale = strtok($locale, ";");
 }
?>
<script type="text/javascript" src="dojo/dojo.js" djConfig="parseOnLoad:true,locale:'<?=$locale?>'"> </script>

Note the djConfig attribute when including the dojo.js file. It specifies the locale to be used.

Posted in Ajax, Dojo, i18n, Javascript, open source, Technical | Leave a Comment »

Microsoft are thieves, and I like it

Posted by Shane O'Sullivan on September 9, 2008

The Internet Explorer team recently posted an article about additions to IE8 that will help Ajax developers – see http://blogs.msdn.com/ie/archive/2008/09/09/what-s-new-for-jscript-for-ie8-beta-2.aspx . In it, they describe some of the features of Firebug that they are blatantly copying, including:

  • Script debugger –  step through your JavaScript code, place breakpoints etc.  A nice addition is coloured syntax, which hopefully Firebug will have soon.
  • Script profiler, for indentifying performance bottlenecks.

I think it’s great that MS are taking one side of the open source movement to heart – the free sharing of ideas for the benefit of all.  This will make developing web application of IE infinitely less painful (i.e. possible).

Now if only they would scratch the back of the open source community, and stop patenting and locking down every good idea to come out of Redmond, just imagine how good things could get!

Of course this is not about to happen (an open source IE?? Um, no).  But we can dream.

Posted in Ajax, Javascript, Technical | 2 Comments »

 
Follow

Get every new post delivered to your Inbox.

Join 533 other followers

%d bloggers like this: