Posts Tagged ‘javascript’

Making Yahoo BOSS easier with yboss

Monday, November 10th, 2008

Having had a lot of hackers at the Open Hack Day Brazil get confused on how to use the JavaScript output of Yahoo’s Open Search platform BOSS I’ve spent a short while to write a wrapper library for it. You can now easily search the web, images and news of Yahoo in one go with a few lines of code:

<div id="results"></div>
<script type="text/javascript" src="yboss-lib.js">
</script>
<script type="text/javascript">
YBOSS.get(
  {
    searches:'search,images,news',
    query:'obama',
    count:10,
    callback:seeddata
  }
);
function seeddata(o){
 var all = '<h4>Web Sites</h4>' + o.webHTML + 
              '<h4>News</h4>' + o.newsHTML +
             '<h4>Images</h4>' + o.imagesHTML;
 var out = document.getElementById('results');
 out.innerHTML = all;
}
</script>

The wrapper does all the work for you: creating the different script nodes calling the BOSS API with the right parameters and either returning a JSON object with all the mandatory search data (links in a certain format) or returning a bunch of HTML lists that can be printed out as innerHTML anywhere you like.

Check out the yboss homepage and download the script for yourself. The hackers at the Hack Day loved it and the winning hack in the BOSS category was based on it. Also check out the presentation I’ve given on BOSS at the hack day to learn all about the system itself:

JavaScript and BOSS- Open Hack Day Brazil

JavaScript and BOSS- Open Hack Day Brazil

A quick introduction to the BOSS REST API and how to use it in JavaScript using YUI3. Make sure to also download the code examples: http://icant.co.uk/stuff/bosscodebr.zip

Read "JavaScript and BOSS- Open Hack Day Brazil" with Easy SlideShare

The art and pain of teaching JavaScript - my talk at <head>

Sunday, October 26th, 2008

I just delivered my talk on teaching, learning and writing JavaScript for use. The slides are available on slideshare below and if you don’t want to sign up, I’ve also put them up on S3.

The art and pain of teaching JavaScript

The art and pain of teaching JavaScript

My slides for the head conference 2008 explaining how hard it is to write JavaScript solutions that cater for all the users out there and what can be done to avoid us creating a lot of material that is outdated as soon as it comes out.

Read "The art and pain of teaching JavaScript" with Easy SlideShare

I’ve covered the different types of JavaScript consumers: Users, Tinkerers (explaining that there is nothing derogative about this term), Implementers and Developers. I then started to explain where these people come from, what they expect and how we can reach them.

Other topics where how to battle successful but outdated information, ideas how to keep systems upgradeable and generally to consider moving away from an “OMG Ponies! Technology! Let me show you what I can do” to a “Here’s why I love using this and this is how I did it” approach.

Hopefully I inspired some people. I thoroughly enjoyed the session, although it is weird to talk to a monitor :)

Maintainable JavaScript - Videos of my Fronteers talk are now available

Saturday, October 11th, 2008

The lovely people (check the interview to see what I mean) at Bachelor ICT just released “the videos of my talk about Maintainable JavaScript”http://www.bachelor-ict.nl/christian-heilmann at the Fronteers conference in Amsterdam:

Here’s part one of the talk:


Chris Heilmann: Maintainable JavaScript, part 1 from Bachelor-ict.nl on Vimeo.

And Part 2:


Christian Heilmann: Maintainable JavaScript, part 2 from Bachelor-ict.nl on Vimeo.

They also interviewed me after the talk to re-iterate some of the points:


Christian Heilmann: Maintainable JavaScript from Bachelor-ict.nl on Vimeo.

Great job guys, thank you!

You can find the slides of the talk at slideshare.

Useful tweets widget using Yahoo Pipes and some JavaScript

Sunday, September 28th, 2008

If you look on the right side of this blog (and you can see) and you have JavaScript enabled you’ll spy a little “Useful tweets” widget (list). This is done with Yahoo Pipes and some JavaScript. As people asked me how it is done, here goes:

The idea

I use twitter a lot. Some of what I write is very relevant to the blog here, some is not fit for publication and some is just personal. So publishing all the tweets here would have been disruptive, hence I tried to find a way to filter things down.

What I do is that I end every tweet that I want to show up here with a § symbol, thus giving me a handle to filter out the good ones.

Playing nice with twitter and not summoning the fail whale

As twitter is probably the most hit API out there I didn’t want to go through the API and all the authentication malarkey. Instead I am using the ATOM feed and pipes to get the information and to filter it down.

Yahoo pipes is still full of win when it comes to filtering, mashing and converting data, and the pipe in question that I am using is available here: Useful tweets pipe

It takes the atom feed of a twitter user of a certain ID, removes all tweets but the ones ending in a § and removes the user name of the output.

Using the pipe and displaying the content

In order to display the pipe all you need is a small JavaScript and the right HTML in your page (or in my case WordPress template):


<div id="mytweet" class="user-13567">
  <a href="http://twitter.com/codepo8">My useful twitter updates</a>
</div>
<script type="text/javascript"
 src="http://usefulltweets.googlecode.com/files/chirpchirp.js"></script>

The link means the thing still makes sense when JavaScript is not available and the script does the rest. One thing you need to do to show your useful tweets instead of mine is to change the class on the DIV! You get the number from your twitter page:

  • Go to your twitter page, f.e.: http://twitter.com/codepo8
  • Click the RSS link at the bottom
  • Check the URL of the feed, your ID is the number in between the slash and ‘.rss’, f.e.: http://twitter.com/statuses/user_timeline/13567.rss

The JavaScript for display of the badge is no rocket science whatsoever:


var tweets = function(){
  var x = document.getElementById('mytweet');
  if(x){
    var twitterUserId = x.className.replace('user-','');
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.src = 'http://pipes.yahoo.com/pipes/pipe.run?' + 
    '_id=f7229d01b79e508d543fb84e8a0abb0d&_render=json' +
    '&id=' + twitterUserId + '&_callback=tweets.tweet';
    document.getElementsByTagName('head')[0].appendChild(s);
  };
  function tweet(data){
      if(data && data.value && data.value.items){
          if(typeof data.value.items.length !== ‘undefined’){
            var ul = document.createElement(’ul’);
            var all = data.value.items.length;
            var end = all > 5 ? 5 : all;
            for(var i=0;i < end;i++){
              var now = data.value.items[i];
              var li = document.createElement(’li’);
              var a = document.createElement(’a');
              a.href = now.link;
              a.appendChild(document.createTextNode(now.title));
              li.appendChild(a);
              ul.appendChild(li);
            }
            x.appendChild(ul);
        }
      }
    };
  return{
    tweet:tweet
  }
}();
  • We check if the element with the ID mytweet exists
  • We then extract the user ID from the class name and create a new JavaScript pointing to the JSON output of the pipe. This, once loaded, will call tweets.tweet() and send the data as JSON
  • The tweet() method checks if data was retrieved, creates a list of links and appends it to the DIV.

Hope this is useful to someone else, too.

Scripting Enabled at @mediaAjax 2008

Monday, September 15th, 2008

I am right now at @media Ajax 2008 getting ready to go on stage to deliver my “Scripting Enabled” talk, explaining how the main issue about accessibility is that we just don’t talk enough to each other. Technology is never really the boundary we have with accessibility, it is that we don’t understand how people work and what technology is capable of.

Links in the presentation

Wait till I come! is the blog of , a developer evangelist living and working in London, England. Download vcard.

Feed me, Seymour: Entries (RSS) and Comments (RSS).