Christian Heilmann

You are currently browsing the archives for the General category.

Archive for the ‘General’ Category

JavaScript and Webservices – my talk at the Ajax Experience Boston 2009

Wednesday, September 16th, 2009

I am currently at the Ajax Experience conference in Boston, MA and yesterday I had my hour of fame giving my talk about “JavaScript and Web Services”. Here are the slides and the audio recording of my talk.

You can also check the audio recording of the talk at archive.org

In the talk I covered the change from the old web of documents and pages to a web of data, how we should liberate ourselves from browser restrictions when playing with technology and how YQL allows you to easily remix the web and use JavaScript on the command line with all kind of fancy options that you don’t have in browsers.

Resources mentioned are:

Shipping out to Boston – Ajax Experience and brownbag at your place?

Friday, September 11th, 2009

I just came back from a quick holiday (4 days offline, 810 emails and endless stuff in Google reader) so please bear with me if you sent me a message the last few days. Tomorrow I am off to the US again to go to Boston:

The actual reason of course is the Ajax Experience and I tacked a few days after the conference on to be able to visit our Yahoo offices in Cambridge and maybe come around to your company to give a brownbag session. So if you are in the area comment here, or ping me on Twitter – I am @codepo8. Tomorrow I will be in the air but from them on I am in the hotel of the conference.

Yay for east coast!

Chris

Introduction to W3C widgets – my presentation at Brighton Barcamp 4

Sunday, September 6th, 2009

This saturday I went down to Brighton to attend the fourth Brighton Barcamp. As you are supposed to give a talk and PPK had stopped over on his way to the airport I thought the time right to give a talk about what I learnt about W3C widgets working with PPK and Vodafone the last few weeks:

  • Whilst W3C widgets are nothing groundbreakingly new, they allow you to use web technologies (CSS, HTML, JS) on lots and lots of mobile phones
  • The main idea about a widget is not what technology you use but how useful the end product is. My submission for the summer of widgets competition is neither a visual nor a technical masterpiece, but it still won a weekly prize because of its usefulness.
  • W3C Widgets are a great opportunity to bring our web development skillsets to a new market and break into a very closed environment
  • It is a lot of fun to build them, as you are not tethered by bad browser implementations and you can use clever things in your JavaScript

Check out the slidecast on SlideShare:

The audio quality is not the best mainly because of the location (in the basement) and Simon Willison delivering a very loud talk about 5 meters down the hall.

You can also get the audio recording – 17MB MP3 from archive.org

TTMMHTM: Apptember, fonts to embed, time API, mobile frameworks and charity hacks

Wednesday, September 2nd, 2009

Things that made me happy this morning:

  • There is a new cafe in my street: Maria e Munti - new cafe around my streetMaria e Munti - new cafe around my street
  • Font Squirrel has a repository of free fonts to embed via @font-face
  • Apptember is a one-month hackathon, no rules, no business model, no prices – just build some good stuff
  • Man builds house from Lego – now this is dedication.
  • Some very impressive photorealistic Star Wars Illustrations
  • Blockchalk has an API now and I am impressed with the ease of approach to keep it totally open
  • Both jQTouch and Pretty Mobile are frameworks to make mobile web development easier
  • Baseline is a typographical CSS framework
  • The Time API is a very clever semantic API that understands natural language to turn it into timestamps
  • Browser for the better is a Microsoft campaign that provides food for homeless people when you upgrade to IE8. Seems a bit stretched, but hey upgrade is good!
  • Charity Hack is a hackday by Paypal an Justgiving on 19-20th of September in London
  • Top Trumps 3D is an interesting concept of Top Trumps with 2D barcodes that turn into augmented reality games.

Converting a data table on the web to an autocomplete translator with YQL and YUI

Monday, August 31st, 2009

During the Summer of Widgets hack event last weekend, Tomas Caspers, Nina Wieland and Jens Grochdreis had the idea of creating a translation tool to translate from the local Cologne accent to German and back.

For this, they found a pretty impressive data source on the web, namely this web site by Reinhard Kaaden. The task was now to turn this into a fancy interface to make it easy for people to enter a “Kölsch” term and get the German equivalent and vice versa. For this, I proposed YQL und YUI and here is a step-by-step explanation of how you can do it.

You can see the final outcome here: Deutsch-Kölsch übersetzer
or by clicking the screenshot:

Deutsch-Koelsch Uebersetzer by  you.

Step 1: Retrieve and convert the data

A very easy way to get data from the web is using YQL. In order to get the whole HTML of the source page all we had to do is select * from html where url='http://www.magicvillage.de/~reinhard_kaaden/d-k.html'. That gave us the whole data though and we only wanted to get the content of the tables.

Using Firebug and looking up some XPATH we came up with the following statement that would give us the language pairs as German-Koelsch inside paragraphs: //table[1]/tr/td/p[not(a)]. The not(a) statement is needed to filter out the A-Z navigation table cells. We chose JSON as the output format in YQL and dktrans as the callback function name.

All in all this gave us a URL that would load the data we wanted and send it to the function dktrans once it has been pulled:



All that had to go in there to create the Autocomplete controls was more or less 100% copied from the simple Autocomplete example on the YUI site.
First thing is to get some handlers to the input fields I want to populate with the translation data:

var di = YAHOO.util.Dom.get('deutschinput');
var ci = YAHOO.util.Dom.get('koelschinput');

Then you need to instantiate the data source for the autocomplete and give it the language array. As a responseSchema you can define a field called term:

dktransdata.cologneDS = new YAHOO.util.LocalDataSource(
dktransdata.koelsch
);
dktransdata.cologneDS.responseSchema = {fields:['term']};

Next you need to instantiate the AutoComplete widget. This one gets three parameters: the input element, the output container and the data source. You can set useShadow to get a small dropshadow on the container:

dktransdata.cologneAC = new YAHOO.widget.AutoComplete(
'koelschinput','koelschoutput',dktransdata.cologneDS
);
dktransdata.cologneAC.useShadow = true;

This turns the input of the Cologne language into an Autocomplete, but it doesn’t yet populate the other field. For this we need to subscribe to the itemSelectEvent of the AutoComplete widget. The event handler of that event gets a few parameters, the text content of the chosen element is the first element of the third element in the second parameter (this is explained in detail on the YUI site). All you need to do is set the value of the other field to the corresponding element of the translation maps we defined:

dktransdata.cologneAC.itemSelectEvent.subscribe(cologneHandler);
function cologneHandler(s,a){
di.value = dktransdata.dk[a[2][0]];
}

All that is left is to do the same for the German to Cologne field:


dktransdata.germanDS = new YAHOO.util.LocalDataSource(
dktransdata.deutsch
);
dktransdata.germanDS.responseSchema = {fields:['term']};
dktransdata.germanAC = new YAHOO.widget.AutoComplete(
'deutschinput','deutschoutput',dktransdata.germanDS
);
dktransdata.germanAC.useShadow = true;
dktransdata.germanAC.itemSelectEvent.subscribe(germanHandler);
function germanHandler(s,a){
ci.value = dktransdata.kd[a[2][0]];
}

Step 5:Putting it all together

You can see the full source of the translation tool on GitHub and can download it there, too.
Of course we are not really finished here as this only works in JavaScript environments. As the translator was meant to be a widget though, this was not an issue. That the autocomplete does not seem to work on mobiles is one, though :).

Making this work without JavaScript would be pretty easy, too. As the data is returned in JSON we can also use this in PHP and write a simple form script If wanted, I can do that later.