Technology

JavaScript debugging with Internet Explorer

Oliver Brown
— This upcoming video may not be available to view yet.

Ever had a problem with JavaScript? If you don’t realise that’s a rhetorical question then go away now…

I had a simple script that worked fine in Firefox and Opera but not in IE. I got the amazingly useful message “Object expected” at line 0, character 0. So after looking around for a bit I found the Microsoft Script Debugger. And it’s actually quite good. Not as convenient as Firefox (since most of my problems are syntax errors) but it solved my problem. And in a way, I can blame Firefox and Opera for the problem. Maybe.

“class” is a reserved word in JScript (IE’s JavaScript engine) but it isn’t in Firefox and Opera. Perhaps it should be. Then perhaps not since contrary to popular belief, JavaScript (or technically ECMAScript) is not an object orientated language (at least not in the traditional sense), it’s a prototype language.

The main difference is a prototype language does not have classes (which is why “class” is not a reserved word in Firefox or IE), objects are given functionality on a per instance basis.

All this is rather academic though. If you need to debug JavaScript in IE for whatever reason, get the debugger. And ignore the link that says there is a newer version available - it’s pointing to Visual Studio .NET 2003.

Switching to a Mac is getting easier

Oliver Brown
— This upcoming video may not be available to view yet.

Unless you’ve been living under a rock for the past couple of weeks (possible admittedly - you could have been on holiday) you’ve probably heard that you can now run Windows XP on an Intel Mac using Boot Camp. This could be a great step forward for Apple with regards to capturing Windows users.

Firstly I don’t think Apple will capture the casual market, at least not in the near future. However much certain Mac enthusiasts may claim Macs are easier to use, a Windows machine does everything the casual user wants it to do (and because of the market share of Microsoft it does it the way the expect it to. Not only that but some of the details about installing Windows on a Mac are too much for the casual user (look for the confused look when you explain to them that if they use an NTFS partition to put Windows on the Mac won’t be able to write it. Then see how they laugh when you mention FAT32 as an alternative). The slightly more technical fraction of the market is much more obtainable.

Those with enough confidence with computers to manage the transition may now be willing to make the change. Before, buying a Mac was a big step. Unless you wanted to have two computers it meant giving up a lot. Now you can have the best of both worlds with just one computer. For developers this could be great. With the increasing success of Mono as a cross platform development environment, have a single computer to test everything on (whether it’s been done or not I’m sure it’s technically feasible to run Linux on an Intel Mac). This will ultimate increase the number of developers able to work with Macs and the whole things spirals outwards.

Perhaps.

Going more mobile

Oliver Brown
— This upcoming video may not be available to view yet.

I announced limited support for mobile devices viewing the blog recently. That support basically only covered phones with Opera Mini.

Well now I have a WML theme installed so you should be able to view the site with any WAP device.

You can force WML output with any browser though (although most browsers do not understand WML).

Detecting Mobile Phones

You’re first instinct is probably to check the user agent. Although it’s true there are fairly consistent ways to detect a phone from the user-agent there is a better way.

One of the many under-utilised headers that browsers always send (well 99.99% of browsers you encounter will) is called Accept. This is just a list of MIME types that the browser can handle. Since all mobile phones (as well as PDAs can display WML pages, we’ll use this as the basis to detect mobile devices. The MIME type for WML pages always seemed rather odd to me: text/vnd.wap.wml.

if (strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false) $mobile = true;

Now we need to find out if the phone can accept XHTML Basic (or XHTML Mobile Profile or whatever) in pretty much the same way:

if (strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false) $xhtml = true;

Many “real” browsers are inconsistent with regards to the MIME type for XHTML. As far as I know since mobile phones do not have any sort of backwards compatibility issues they all use the proper application/xhtml+xml.

XHTML Compliant - Thrice!

Oliver Brown
— This upcoming video may not be available to view yet.

I tried validating the markup and my site and found a few errors (nobr tag not allowed, span tag not allowed inside a ul and few others) so I fixed them and I’m XHTML 1.1 compliant once again. That is the home page and a few random pages I tried are compliant. There are probably some posts with random stuff that isn’t…

The main reason I did it was for the sake of any mobile browsers that might complain really loudly about bad markup. So I started reading about XHTML Basic what exactly was and wasn’t allowed. Well I couldn’t find anything useful so I just tried validating as XHTML Basic 1.0. I had to remove script tags, style attributes, replace i with em and again, a few other minor things. The end result is that an XHTML Basic version of the site is available to mobile browsers. Since I don’t have a mobile browser to test it on I can’t guarantee I’m detecting them properly yet. If you want to see what it looks like though, just go to Oliver Brown - Basic.

Then I discovered that it’s mainly PDAs that use XHTML Basic and that mobile phones tend to want XHTML Mobile Profile (XHTML MP also called WAP 2.0). Just changing the doctype was enough to get XHTML Basic to validate as XHTML MP. You can check it out at Oliver Brown - Mobile (it looks the same as Basic).

Just to let you know, when browsing the other versions manually all the links bring you back to the normal site - you actually need a browser detected as being a mobile phone for it to work properly.

StepMania

Oliver Brown
— This upcoming video may not be available to view yet.

Think of this as an introductory post into something I may mention more in the future. This way I can just send people here instead of explaining everything from scratch every time :P

Ever heard of Dance Dance Revolution (Dancing Stage in Europe)? Well it’s a funky arcade game you control by “dancing”. Arrows scroll up the screen and when they reach the top you press the corresponding button.

The really cool thing is a an open source PC version of it called StepMania. Generally StepMania has more features and allows you to add as many songs as you want (assuming you can get the media files and step charts). In fact there are arcade machines around that are actually a computer running StepMania inside a DDR cabinet (which is a little overwhelming to play because of the sheer number of songs available.

Random traffic according to Analytics

Oliver Brown
— This upcoming video may not be available to view yet.

Firstly, after using it for a week I’ve concluded Google Analytics is good. I can’t reasonable access any of it on a dial-up connection but that should be an increasingly small problem. (Increasingly small? Almost as good as “it’s looking more and more less likely”.)

One thing it reveals is random search engine traffic I get for almost no reason. I posted about the April fools gag on GameFAQs and I’m now on the second page of Google if you search for GameFAQs. The funny (although understandable) bit it is that it’s my internal search page for GameFAQs that is actually in the results.

Language learning ideas - bringing it all together

Oliver Brown
— This upcoming video may not be available to view yet.

This post, like many of my others on the topic ramble a bit. You have been warned :P

Any regular readers I might have will know how much I like Pimsleur products for learning experience. I believe the basic idea can be greatly enhanced with computers. I did in fact try a short time ago but suffered from a lack of voice talent which is where speech synthesis could be useful.

Synthesised voices can be imported into the current system (which at the moment I wouldn’t be able to demonstrate since the voices need to be licensed if they are to be distributed) just by recording them to audio. This solution would allow maximum support since any browser with audio capabilities could use the system.

There is an advantage to using the IE plugin though (or any other system supporting SALT) - speech recognition. It should be entirely possible to actually have a browser based system that checks your pronunciation which would instantly make it better than any system out there.

Quite why none of the companies that create these synthetic voices have tried to develop a system like this I don’t know…

Learn a language with synthetic speech

Oliver Brown
— This upcoming video may not be available to view yet.

I’m currently working out how feasible computer based language-learning-type software using synthesised speech would be. Speech synthesis has improved a great deal recently and although it’s still not as good as a real person (although I believe it could be soon - at least for non-emotive situation) it could just good enough.

The traditional way to generate speech with a computer is algorithmically. Essentially someone works out how to overlay tones with different pitches and wave-shapes to form each sound. The newer way is to actually record each sound manually and essentially play them back one after the other.

There are more stages it to it than that - assuming you don’t want to write the speech phonetically (in IPA for instance) there also needs to be a way of turning text into phonetic information. This is usually half dictionary based for common words and syllables and half rule based (to avoid having a big dictionary and for coping with languages constantly expanding and evolving).

So we now have technology (almost freely available) that can produce speech that is good enough given the correct phonetic information - it’s the actualy language processing that is problematic. Most of the work is done by American companies and therefore most of the work is done processing English (American English at that).

This is not an insurmountable problem. The engine I’ve been playing with (available as an addin to Internet Explorer and as standard on Windows Vista) works fairly well with foreign words transcribed in dodgy-phonetic English. For example to get it to pronounce “Entshuldigung” (German) correctly you need to type “Enshooldicken”). This is workable for an semi-automated system - it could include a dictionary of sorts replacing words with their English-phonetics version.

I know the whole of this article is rather rambling - I’ll post something more readable later :P

More stable server

Oliver Brown
— This upcoming video may not be available to view yet.

The server should now be up far more often.

I can’t work out why MySQL and/or Apache keep crashing so often so as an interim solution I’ve just written a PHP script that is run by the cron daemon that checks each if they are running as they should and restarts them if they’re not. Hopefully this means if the server is down it shouldn’t be for more than an hour.

More Google Analytics

Oliver Brown
— This upcoming video may not be available to view yet.

Well I now have to say that Google Analytics certainly looks impressive. It has all the stats that you would expect from anything and a heck of a load that you wouldn’t. The real gain is the way it is presented. All the stats can be quickly restricted to date ranges, you can compare two date ranges, most of the details can be combined arbitrarily (just see visitors from Spain using Internet Explorer on Macs for instances) as well as lots of other nifty things. It also has support for e-commerce tracking (including defining custom goals and ROI calculations) as well download and outbound link tracking.

And it’s free.

Well if you have more than 5 million hits a month you need to get a Google AdWords account which (at least when I signed up) needed a $5 deposit. But if you get 5 million hits a month I’d hope you could afford it.

One quick detail I discovered (without really looking for it). I get most of my traffic from search engines, however visitors from links from other sites visit more pages per visit.

I’ll post more as and when I find something particularly interesting to post (for instance I can’t test the date features with just one day of data).