Great HTML5 Canvas/ Chrome Demo sites

Found this today; www.chromeexperiments.com loads of cool canvas experiments- geared towards google chrome but most run well in up to date firefox build.

Update: also worth a look in; www.canvasdemos.com

No Comments

ASP.net update panel’s and jQuery

I had a problem today with buttons in an update panel and jQuery- there are some buttons which get hidden or displayed depending on the user’s OS – mac or pc users basically get shown different instructions- However because these buttons are added by a partial post back of the update panel, the jQuery document.ready had already fired before these buttons existed.

So I experimented adding the code to the form.submit event but in the end found the solution on google; I simply added this;

<script type='text/javascript'>
function pageLoad(sender, args)
{
    // your code here..
    showHideMacLinks();
}
</script>

This handles the pageLoad event raised by my update panel which is fired on the initial load and on the partial post back.  You can filter this to only fire on partial post back by adding  “if(args.get_isPartialLoad())”

Found this over on the .net Funda blog

No Comments

Just Won an MSDN Ultimate Subscription!!

I just won a competition, which in itself is quite amazing as i never win anything- but the prize is an MSDN Ultimate Subscription!!!  Checkout the announcment over on the Less Than Dot Blog!  Many thanks to Denis Gobo & Ted Krueger!

No Comments

Couple of interesting news items today

Couple of bits I spotted in the news today that I though warranted posting;

I’m particularly interested in the IE9 release 3 to test it out with the html5/ javascript game I’m building for the 8 week game competition

No Comments

FileUpload.PostedFile.Filename includes all the client Path info, but only in IE

This is a known problem documented on the MSDN – I’m sure I’ve been caught by this before so thought i would blog it!

Firefox and IE7.05XX treat the PostedFile.Filename property differently.

In Firefox, calling FileUpload.PostedFile.Filename will return the name of the file, with no path information.

In IE7, calling FileUpload.PostedFile.Filename will return the full path of the file + the filename.

e.g. if the client file is located at c:\My Documents\Test.xls, Firefox will return ‘Test.xls’, and IE7 will return ‘c:\My Documents\Test.xls’

No Comments

Google Font API

Just stumbled across the Google Font API- it’s a (at the moment) small directory of open source fonts hosted by google which can be used on your website via their font API. Looking at the quick start it just seems to be a matter of adding an include to your page, then referencing the fonts in your css, like you would any other font. Clever stuff!

No Comments

Example update with left outer join in SQL Server

I always seem to remember the access syntax for this rather than the sql server version–

update
    hachette_digitalideas_import
set
    harrietId = u.Id
from
    hachette_digitalideas_import h
    left outer join user_group u
        ON (h.email = u.email or h.[full name] = u.name) AND u.btype = 'u'

As opposed to the following in access;

update
    hachette_digitalideas_import
    left outer join user_group u
        ON (h.email = u.email or h.[full name] = u.name) AND u.btype = 'u'
set
    harrietId = u.Id

No Comments

Mac Safari Web Developer Tools (inc javascript debugging!)

make sure you don’t have safari running, then go to the terminal window and type;

defaults write com.apple.Safari IncludeDebugMenu 1

You will have a new menu when you launch safari entitled “develop” in safari 5, and “debug” i believe in earlier versions.

No Comments

HTML5 Audio and Video (Media) Tags – How do you know when the data’s loaded? And how to play multiple instances of the same sample at the same time

Quick post with a snippet of code I’ve used for the 8 week game competition I’m in- I’m going to be using html5 audio element for all my game’s sounds and needed a way to make sure the samples were totally loaded so the resource manager knows when to hand control to the game- So after flicking through the html5 spec came up with this code (utilising jQuery to bind my event handler)

Note- This applies to any media object- so the video tag as well, but I’ve only tried this with audio.

// http://www.whatwg.org/specs/web-apps/current-work/#mediaevents
// http://api.jquery.com/bind/
var ao = new Audio();
$(ao).bind('canplaythrough', function() { // totally loaded
alert('ready to play');
});
ao.src = 'sounds/my_sound.wav';
ao.load();

The above example will wait until the media element has enough data to comfortably play through without stopping to buffer. if you wanted you could also bind to a whole host of other events in exactly the same way, which you can read about here. You can check the status at any time to see how loaded the audio/video file is like this;

ao.readyState;

This will return you back a number between 0 (HAVE_NOTHING) to 4 (HAVE_ENOUGH_DATA) – full info can be found here.

Because I’m building a game I have slightly different requirements to the average web project- The way I use this is have a central “ResourceLoader” which I load up with all the url’s to the asset’s I’ll be using, this then reports when all the assets are totally loaded and hands control to the game. So there is a single instance of every image and audio element I’m using- I then hand each loaded sound to the sound manager to play. This raises a problem when i want to play the same sample more than once, overlapping because you are essentially just passing around reference to the same audio object- so i execute the play method, then execute it again and nothing happens because it is already playing! The answer is to perform a deep copy of the audio element before playing- because this is a DOM object you can do this easily like so;

// https://developer.mozilla.org/en/CloneNode
var instance1 = ao.cloneNode(true);
var instance2 = ao.cloneNode(true);
instance1.play();
instance2.play();

This way you can hit the play() method of instance1, and the instance2 and they will both play at the same time, totally independant of each other, even though they both originate from the pre-loaded instance ao.

Anyway- you can see live demos of this here;

Notice the need for 2 demos because chrome cant read wav and mozilla wont do MP3! Ogg vorbis is a common format for the two, but i couldn’t quickly find any example files to use! Read here for browser file format support.

These demo’s were made for us in the 8weekgame site – bare in mind the sound manager class I literally started about an hour ago so it’s got hardly any functionality but it does play sounds so take a look at the source code and hopefully it will all make sense!

No Comments

Wordpress 500 Error when submitting a blank comment form under IIS7 and PHP5

I recently noticed an issue on this very blog and a couple i have hosted on this server when people just hit submit on the comment form without entering anything into the comment field- i would get a 500 server error back.

error_pagesI spent ages googling figuring it was some kind of config error on the server as it happened across all of the wordpress blogs on this server- I eventually found it wasn’t an error at all- The skins used across these blogs didn’t seem to validate the forms so it was falling back to wordpress which was returning an error like “Error: please type a comment.”- however IIS seemed to be intercepting this as a full error and rendering a 500 error- the solution was simple!  Turn on detailed error’s.  Obviously this isn’t good on a production box running dot net, but for PHP you can control the error reporting from within the php.ini file anyway, so this just makes sure IIS doesn’t add an additional layer of error filtering confusing matters.

Update: Thanks to Kanwaljeet Singla on the comments for pointing out a better fix for this as detailed on Kern Handa’s blog here.  This can basically be fixed easily by setting a web config entry to tell IIS to let errors pass through, like so;

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors existingResponse="PassThrough" />
    </system.webServer>
</configuration>

2 Comments