Archive for the ‘Client-side Programming’ Category

PNG 24 Round Up

Monday, November 27th, 2006



PNG24’s are the answer to all our prayers. Now I know what you’re thinking: “PNG’s have been around forever…what’s the biggie?” Well the biggie is that IE 7 is now supporting PNG24’s which means that we can start doing some awesome stuff without having to hack our code to shit! Unfortunately it’s still going to take a wee while for IE 7 to filter down to most users machines so we’ll still have to do a little bit of hacking for our dear friend IE 6
(more…)

Web Directions Day One

Friday, September 29th, 2006

Day one started out with Kelly Goto’s keynote on lifestyle design. She covered some interesting topics, the main theme being the way in which we’re trying to make technology more ‘human’. She showed us a few examples of the turning effect - probably the most popular one being the Subservient Chicken.
(more…)

Scripting in the 21st Century

Wednesday, October 26th, 2005

I love scripting.

I - like most web designers - have spent many hours viewing source on pages that have nifty script trickery. I’ve always loved that one can learn JavaScript just by stealing (read: borrowing) other people’s code. (That’s probably why I’ve never bothered learning Flash.)

Back in the early days scripting was used mainly for rollovers and form validation. Back then it was all you needed. Everything was new and undiscovered. People weren’t thinking about accessibility or standards, we just wanted to be able to make that image over there change when you moused over some text over here. For me it was about getting my website to do what that other webdeveloper’s websites did. One my favorite sites was bratta.com (now defunct, but there is a back up here). I would spend hours and hours trawling through his code trying to figure out how the fuck he did it! As you’ll see if you go to the above URL most of the scripting is now completely useless.

Now days people are using scripts for far smarter things. The days of whizz-bang are over. Scripts are now used to enhance usability and the user experience. Applications like GMail, Flickr and Basecamp use a fair amount of JavaScript, and a lot of the time you don’t even notice. This is how it should be. JavaScript is the subtlety added to web interfaces. Things like the ‘yellow fade technique‘ and plugging new elements onto the DOM are the way to go these days. Less is more.

So, now that I’ve been rambling for a scroll or two it’s probably about time I cough up some documentation and linkage. I’ve broken the links down into four sections: Documentation; Libraries; Blogs; and The Others.

Documentation

JavaScript documentation is rare and quite unusable…but I’ve managed to find a few gems:

Libraries

These libraries are mainly JavaScript libraries, some have a stronger focus on AJAX, however.

Blogs

The Others

These are links I couldn’t categorise…

So that’s all I have for the time being. If you know of any awesome links I’ve left out please add to the comment form.

Google Maps almost global…

Saturday, June 25th, 2005

A while ago I did my own version of the google memory map thing as google didn’t have satellite images of the New Zealand at that point it was pretty much only the U S of A.

Google now seems to be expanding their satellite coverage. They’ve managed half of Auckland in focus and the other half not.

Its good to see they will be covering the globe in those little google watermarks even if it does take them a while!

delicious linkage

Tuesday, November 23rd, 2004

del.icio.us seems to be the flavour of the month! Bloggers around the world are turning their attention to this amazing system.

I’ve been using del.icio.us for a while now and have finally written some code to integrate it into this here blog.

Thanks to an awesome PHP API I’m now able to access the raw data directly from the del.icio.us web API. Its got method calls for everything in the del.icio.us API, namely:

  • Get posts by date - http://del.icio.us/api/posts/dates
  • Get tags - http://del.icio.us/api/tags/get
  • Get posts by tag/date - http://del.icio.us/api/posts/get
  • Get recent posts - http://del.icio.us/api/posts/recent
  • Get all posts - http://del.icio.us/api/posts/all
  • Add new post - http://del.icio.us/api/posts/add
  • Delete post - http://del.icio.us/api/posts/delete
  • Rename tag - http://del.icio.us/api/tags/rename

I use the PHP API to generate the list of link categories in the bottom navigation and all the links on the links page.

I needed to write three bits of code to get the links page to work as I wanted it to.

XHTML

This was probably the most difficult part. Trying to write perfectly semantic XHTML while still being able to manipulate it with both Javascript and CSS.

I decided to use DL’s for the list of links. The code looks something like this:

<dl class="closed" id="tag_auckland">
    <dt><a href="javascript://" onclick="changeState('tag_auckland')" title="1 links">auckland</a> <a name="tag_auckland">&nbsp;</a></dt>
    <dd><h4><a href="https://connect.aucklandcity.govt.nz/ePathway/0216/Web/default.aspx">Pay Fine</a> <small>[<a href="#top">top</a>]</small></h4></dd>
    <dd>Pay your parking fines in Auckland City online.</dd>
    <dd><small>Related tags: auckland new-zealand</small></dd>
</dl>

I don’t really know why I used DL’s…it may be because I’m totally in love with them at the moment. :) Nevertheless, the end result is totally what I was looking for.

javascript

I used a tiny bit of Javascript perform a sneaky little className change as you can see below:

<script type="text/javascript">
function changeState(this_obj) {
    var obj = document.getElementById(this_obj);
    if (obj.className == &#8216;closed&#8217;) {
        obj.className = &#8216;open&#8217;;
    }
    else if (obj.className == &#8216;open&#8217;) {
        obj.className = &#8216;closed&#8217;;
    }
}

</script>

The function takes the id reference of the HTML element and changes the className from either ‘open’ or ‘closes’ depending on the current className of that element.

CSS

The CSS is actually where all the magic happens. The mix of the Javascript and the below CSS allows for the dynamic showing and hiding of the links.

margin-left: 5px;
text-decoration: none;
clear:both;
background: URL(/images/plus.png) no-repeat 0 6px;
}

dl.closed dt a {
font-variant: small-caps;
font-family: Trebuchet MS;
font-weight: bold;
font-size: 140%;
color: #004675;
text-decoration: none;
padding-left: 15px;
margin: 0;
}

dl.open dt a {
font-variant: small-caps;
font-family: Trebuchet MS;
font-weight: bold;
font-size: 140%;
color: #004675;
padding-left: 15px;
text-decoration: none;
}

dl.closed dd {
display: none;
}

dl.open{
margin-left: 5px;
text-decoration: none;
clear:both;
background: URL(/images/minus.png) no-repeat 0 6px;
}

dl.open dd {
display: inherit;
margin-left: 5px;
}

dl.open dd small {
color: #7EA1B9;
}

dl.open dd h4 {
margin: 5px 0 5px 0;
font-size: 100%;
}

so…?

So now we have all the code we need to build a links page listed by tag name. There is just one more thing left to do…make del.icio.us happy.

‘How?’, you ask. Well, there is nothing del.icio.us hates more than getting its bandwidth raped so I decided to only run this script once every 6 hours. I added a line to the crontab to run the PHP code which then generates an include file (I’ve called mine delicious.inc) that I simply include into the links page of my site. Pretty cool, huh?

I’ve included a link to the PHP code I used. Download it, use it, make it better. Just remember where you got it! ;)

Download PHP file