Terrible Usability on Government Site

Posted in Misc on December 18th, 2009 by helloworlder – Be the first to comment

I just tried to apply for an ABN (Australian Business Number), so I had to visit (shudder) a government site. Why is it that government websites are often the most unusable on the Internet?

The site does not support Firefox. Huh?! Apparently the site also implies that it does not support Windows Vista and Windows 7, the latest supported OS being Windows XP. Right. Browsers that work with the site are IE and Netscape Navigator.

The last time I tried to use a government site was when I was going overseas and wanted to apply with Smart Traveller, which is a government office that takes care of Australian overseas during emergencies. Maybe it’s just that I’m stupid, or that the form was completely unusable. Now this.

Anyway, I fired up IE and managed to get the site working. Here are some screen shots highlighting some problems with the site.

screenshot of website 1

screenshot 1

screenshot 2

screenshot 2

screenshot 3

screenshot 3

Javascript Tutorial - Digg Style Selectors

Posted in javascript, tutorials on December 5th, 2009 by helloworlder – 5 Comments

If you’ve posted stories to Digg before then you’re familiar with the “Choose a Topic” form. This form allows you to select which category your Digg submission belong and then lets you submit the form, all without using radio buttons. This tutorial tells you how to achieve the same effect. But I warn you that this Javascript code will not be degradable. If it’s any consolation, if you disable JS on the Digg website their form will also not work. I’m not trying to encourage obtrusive Javascript, but this is a tutorial and not production code. If you want you can build on the code to make it non-obstrusive.

digg_selection

Digg’s Choose a Topic form

digg_style_select

Our version of it (it’s better isn’t it?)

First, create a new HTML file with the following code, and call it anything you like:

<html>
<body>
<head>
<title> Digg Style Selectors </title>
<script language="JavaScript" type="text/javascript" src="digg_selector.js"></script>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
</head>

<h1> Digg Style Selectors </h1>

<hr />

<form action="CHANGE_THIS.php" method="POST">

<div id="container">

<a href="javascript://" class="digg_style_link" id="1"> Link 1 </a>
<a href="javascript://" class="digg_style_link" id="2"> Link 2 </a>
<a href="javascript://" class="digg_style_link" id="3"> Link 3 </a>
<a href="javascript://" class="digg_style_link" id="4"> Link 4 </a>

</div>

<input type="hidden" name="hidden_data" id="hidden_data" value="nothing" />
<input type="submit" value="Submit" />

</form>

</body>
</html>

To note here is the inclusion of the “digg_selector.js” file which we will look at next. Also important is the hidden field with the id of “hidden_data”. Since what we’re doing is replacing the functionality of radio buttons with nicely styled links, we need another way to get the information submitted and we do that with the hidden field. That’s where the Javascript file comes in:

window.onload=function() {
    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a'); // get anchors
    for(var j=0;j<containerAnchors.length;j++)
    {
        containerAnchors[j].onclick = handleClick;
    }
};

function handleClick()
{
    document.getElementById('hidden_data').value = this.id;

    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a');

    // unhighlight all the links
    for(var j=0;j++;containerAnchors.length;j++)
    {
        containerAnchors[j].style.backgroundColor = "#eceff6";
        containerAnchors[j].style.color = "#3b5998";
    }

    // highlight the link that was just clicked
    this.style.backgroundColor = "#3b5998";
    this.style.color = "#ffffff";
}

This is simple - there are just 2 functions. Looking at the first one:

window.onload=function() {
    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a'); // get anchors
    for(var j=0;j&lt;containerAnchors.length;j++)
    {
        containerAnchors[j].onclick = handleClick;
    }
};

When the page is loaded, we get all the anchors in the container div (these anchors are the digg style selectors/buttons or whatever you want to call them). Then, inside the for loop we attach an event handler to each anchor, which executes when the anchor is clicked. The event handler is a function called handleClick(), which we look at now:

function handleClick()
{
    document.getElementById('hidden_data').value = this.id;

    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a');

    // unhighlight all the links
    for(var j=0;j<containerAnchors.length;j++)
    {
        containerAnchors[j].style.backgroundColor = "#eceff6";
        containerAnchors[j].style.color = "#3b5998";
    }

    // highlight the link that was just clicked
    this.style.backgroundColor = "#3b5998";
    this.style.color = "#ffffff";
}

The line document.getElementById(’hidden_data’).value = this.id; gets a hold of the hidden field we talked about earlier, and dynamically sets its value to this.id . So what is this.id? Well, this refers to the anchor that gets clicked on. So this.id gets the id of the anchor. The hidden field is set, and when the form is submitted we can get the value of the hidden field in the $_POST['hidden_data'], assuming you’re using PHP.

Finally, here’s the CSS stylesheet, which needs to explanation:

body
{
font-family: "lucida grande", tahoma, verdana, arial, sans-serif;
font-size: 15px;
}

a:link {color: #3b5998}
a:visited {color: #3b5998}
a:hover {color: #3b5998}
a:active {color: #3b5998}

h1 {
font-family: Georgia, serif;
font-style: italic;
font-size: 20px;
font-weight: bold;
}

hr {
color: #A8A8A8;
height: 1px;
}

#container {
margin:0;
margin-top: 20px;
margin-bottom: 20px;
}

.digg_style_link {
color: #3b5998;
padding: 3px;
margin: 3px;
margin-bottom: 20px;
background-color: #eceff6;
text-decoration: none;
border: 1px solid #d4dae8;
}

That’s pretty much all there is to it.

Web App #2 - Another Facebook App

Posted in php on December 3rd, 2009 by helloworlder – Be the first to comment

So, this is my 2nd Facebook book app and it’s an FBML app this time, not an iframe. You can find it at http://apps.facebook.com/makedebate . It’s called “Make Debate” and you can share your (passionate?) opinion on topics with friends and other Facebook users.

It’s more fun (and easier) to build a site using FBML rather than using an IFRAME app. You can just use FBML tags rather than lots of PHP API calls.

Web App #1 - A Facebook App

Posted in Facebook, php on November 23rd, 2009 by helloworlder – Be the first to comment

This was my first Facebook app and can be found at http://apps.facebook.com/try-to-pronounce-it

What the app does it let you upload pronunciations of phrases in a foreign language and share it with others. I think the fatal flaw of this app would have to be that users have to upload WAV files instead of any format they want. This opens up a lot of issues with usability. For example, the windows sound recorder does not by default save the recorded sounds as WAVs, and since WAVs are uncompressed they are large. In addition, streaming WAVs in the browser is awkward - whereas with MP3 files I could just use a SWF player to stream the files in a nice way.

In fact, at once point I had successfully implemented the FFmpeg library to allow the user to upload almost any file type they want, and the app would automatically convert that file to MP3. Also, since the files were all in MP3 format, I could stream it in a nice SWF player. Unfortunately I discovered that the MP3 (and other codecs) were patented and the usage of them wasn’t actually legal. Pesky software patents …

A Web App a Week Challenge

Posted in php on November 4th, 2009 by helloworlder – Be the first to comment

Now I’m back from Europe and starting to look for a job. While the job seeking is going on, I’m going to try to give myself a challenge that is to try and create one web app each week until I get a job!

The first web app should be up in a few days (err, hopefully).

EDIT: Well this is taking more than a week, but I should have my first Facebook App up within a day or two. It’s written in PHP. At first I wanted to use the Codeigniter framework but it was virtually impossible getting it to gel with Facebook so I went with straight PHP, unfortunately.

In Europe

Posted in Misc on October 16th, 2009 by helloworlder – Be the first to comment

I m in Europe at the moment. Have been for the past 2 weeks and will be for another 2 so thats the reason for the lqck of updates. Actually in Paris right now. Cant type much because dont know how to use the french keyboard thus the dodgy punctuation, and Im real tired. So goodnight and ill write somthing in 2 weeks.

The Landing Game

Posted in Misc on September 28th, 2009 by helloworlder – 2 Comments

The Landing Game was originally an experiment I was doing to simulate the forces that act on a plane with “real physics”. Then I couldn’t do that so it kind of turned into a game. Because it wasn’t planned I did a bit of the famous spaghetti coding :-)

Though The Landing Game only has 1 level (lol), I learned a bit about game design. One of the most difficult aspects is getting the difficulty right. Too difficult is frustrating and too easy is just boring. I got some friends to test it and the general feedback was - toooo hard. Furthermore, the instructions were not that clear. I ‘m a huge flight sim fan so it was ok for me. That’s why it’s important to do testing.

Anyway you can play the game here. I haven’t fixed up the difficulty yet because I’m pretty busy preparing to go overseas - so I guess you better be up for the challenge!

hehe

Just showing you that it is actually possible to land the plane even at this difficulty!If you’ve played flight sim before then you might find it easier.
TIP: Remember to flare the plane and keep your eye of the Vert Speed indicator. For more info on flaring, see the wikipedia page on Landing.

EDIT: The game has now been made a lot easier after overwhelming feedback that the game was far too difficult and even “impossible”. Now it might be a bit too easy. The main problem is that it only has 1 level! With multiple levels I can gradually make it harder each level. But, I don’t really have time to work on this anymore so I’m leaving the game in its current form indefinitely.

Unobtrusive AJAX Pagination With Rails

Posted in Ruby on Rails on September 27th, 2009 by helloworlder – 1 Comment

I’ve searched around for unobtrusive AJAX pagination with Ruby on Rails tutorials but the best I’ve found are the ones by Ryan Bates at Railscasts. Pagination with AJAX , followed directly by AJAX History and Bookmarks teaches you how to create unobtrusive AJAX pagination.

Also I was at http://wiki.github.com/mislav/will_paginate/ajax-pagination. I didn’t follow those instructions but took note of the advice NOT to use link_to_remote to try and create unobtrusive pagination because they are actually obtrusive and make life difficult for search engines.

Test your AJAX pagination with the Javascript turned off and it should still work fine. Remember that search engines don’t read Javascript so they just ignore it, so if your AJAX app works with JS turned off then chances are that search engines will do alright on your site.

Life’s Like a Depth-first-search

Posted in Misc on September 22nd, 2009 by helloworlder – Be the first to comment

life_dfs

BadProgramming.com

Posted in Misc on September 22nd, 2009 by helloworlder – Be the first to comment

Just found a site called Bad Programming and unfortunately it looks pretty dead.

However I do like the idea of studying bad coding practices. In programming we talk a lot about code smell which is based on our intuition. But intuition is not magically drawn from the ether. Instead, it comes from our own experiences of past mistakes, right? Some mistakes we learn from, and others we don’t. And there are many mistakes we haven’t made yet. So studying bad practices or anti-patterns helps us to avoid making old mistakes and prevent new ones from being made.

The “Re-inventing The Wheel” anti-pattern is one of my favorites. Whether based on pride or ignorance the result is the same - you waste time solving a problem that has already been solved before. If you use Ruby then you know that RubyGems helps you to address this problem.


Easy AdSense by Unreal