Apr 23
I've been working a lot with JavaScript over the last few months. Part of that is inheriting other peoples old messy code and trying to fix and tidy it. Also I've been making production code as tight as possible to keep filesize down. So below are three online utilities I now find essential.
Stuck with an odd error or just want to double check your code? JSLint will give your code the once over for validation.
Inherited some minified or just plain unreadable code? The JavaScript Beautifier will tidy up your code to make it nice and readable. It also give options as to which type of indents you want (tabs, spaces) and will also automatically detect and decode packed JS too.
And when you're ready for production: JSCompress which offers both minification and packing. I'm use minify, as even though packing can often yield smaller files the unpacking process can have a performance hit itself.
Mar 13
Just came across a little issue with the Google AJAX APIs (which I suspect is mentioned in the docs - but I didn't bother to look) while I was doing a little testing for a different blog post.
So first you call the Google Library:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
Then in my next <script> block I called the load function for jQuery and carried on to start some jQuery goodness e.g.:
<script type="text/javascript">
google.load("jquery", "1.3.2");
$(document).ready(function() {
//Do something fancy with jQuery
}
</script>
But doing this was would cause a "$ is not defined" error. Using the essential firebug extension for firefox I could see that the google.load() functions insert the requested libraries straight after the closing </script> in which they are called. So jQuery was being loaded after I tired to call the .ready().
Easy fix, seperate out your google.load()'s to their own script block and make them the first thing loaded:
<script type="text/javascript">
google.load("jquery", "1.3.2");
</script>
<!-- requested libraries will now be inserted here -->
<script type="text/javascript">
$(document).ready(function() {
//Do something fancy with jQuery
}
</script>
Nov 12
Just a little gotcha I came across at work yesterday, thought I'd post more as a reminder for me really. We had a page using a Spry dataset to generate a sortable table and although it worked perfectly in Internet Explorer and Firefox, IE would show it's "loaded with errors" icon in the status bar. As usual IE was helpful with it's error message "Error: Expected ':'".
I assumed that might be because we weren't fully qualifying the Spry data within the Spry:Region, e.g. we were using {fieldName} instead of {dataSetName::fieldName}. But that wasn't it.
To cut a long and tedious story short, it was where we were passing a Spry binded field to a function - function({fieldName}). As the argument was an integer I didn't think it need quotes (and as I said, it still worked in both browsers and IE was the only one to show an error) but when I added single quotes - function('{fieldName}') - IE stopped whining and all carried on working fine.
Not sure if that's a known thing or if it'll help anyone, but it annoyed me for a couple of hours.
Nov 5
So I've had my T-Mobile G1 for 3 days and I thought I'd post my first impressions.
After putting in the sim card, battery then switching on you're immediately asked for your Google account details (or create a new account). It takes a couple of minutes to link up to your account and sync the mail, contacts and calendar. I loved that part, being back to the online synchronised stuff like when I had an HTC Wizard and an Exchange account. But my first night playing left me thinking there's plenty of faults with it. It's plasticy, the camera is pretty naff (especially compared to the N95's fairly decent one), the touch screen didn't seem very sensitive, there seems too be many interface devices (touch, trackball, keyboard, buttons) and more...
I was disappointed and was seriously considering sending it back. But these all seemed to be hardware issues, Android, the software, is actually very nice. Okay, it doesn't have the "impress-your-mates-easily" multi-touch but the interface is pretty solid. I like the notification "shutter" pull down, the scrolling physics when you flick lists is very "iPhone" and Android Market seems nice enough with some genuinely handy/clever apps. My first full day with it changed my opinion, I expect I was just getting used to it, but the touch screen felt more responsive. T-Mobile's 3G service around London seemed to fairly robust too, better than my experience with o2's on my N95 in recent weeks. GPS is quick to lock and accurate. Even the multiple interfaces seemed to all seem to have a definite purpose. So it's still early days but it's definitely growing on me and I'm going to stick with it.
I have high hopes for Android in the future, as long as T-Mobile keep abreast of updates (I'm sure they will as it's in their and Google's interest to keep it progressing - and updates over-the-air is a nice touch). Hopefully some of the popular iPhone apps are ported over (the train times one would be a nice start!), or maybe I should just learn a bit of Java and do my own...
And just to confirm Android has MMS, copy & paste and SMS forwarding, take that iPhone users! (I say in jest! I love the iPhone, I'm not one of these fanboy facists) :)
Oct 13
As a little follow up to my post last week about starting to play with the Flex, I took my last.fm user application a little further to include more of the information they expose throught the audioscrobbler site.
Have a play: last.fm flex app v2
Recent Comments