Example usage:
validate("http://www.google.com/",
function(response) {
alert(
"URL: " + response.url + "\n"
+ "Status: " + response.status + "\n"
+ "Errors: " + response.errors + "\n"
+ "Warnings: " + response.warnings + "\n"
+ "Recursion: " + response.recursion
);
}
);
As you can see, the validate() function takes two arguments, the URL to validate and a callback function. The callback function is given a response object that carries the properties as seen in the example. You can also provide an optional third argument which is a function that will be called should something go wrong (only some errors are currently caught by this).
The meaning of the properties are as follows (taken from http://validator.w3.org/docs/api.html#http_headers, go there for more details):- status:
ValidorInvalidif validation was performed.
value will beAbortif a fatal error (decoding, 404 not found, etc) was encountered and validation could not be performed - errors:
Number of Errors found during validation.
0if no errors found. - warnings:
Number of Warnings found during validation.
0if no errors found. - recursion:
Integer. Generally,
1. More if recursively validating validation results.
Demo
Download
validate.jsRead more...
Just a quick post to let you know that I've got an article up at Dev.Opera where I talk about creating a simple raycasting engine like the one I used in my WolfenFlickr project. Read the whole article here. Feel free to ask questions and leave comments both here and at dev.opera.com.
Read more...
Ernest Delgado has turned my Mario Kart demo into a map navigation tool. Neat! This just popped up in my referrer logs and caught my eye. Ernest Delgado has taken apart the code from my Mario Kart project and turned it into a cool map navigation demo that dynamically downloads map tiles from http://openstreetmap.org/. Pretty cool, check it out here,
Today is the birthday of Benoit Mandelbrot.
About 30 years ago he pulled a bit of mathematical beauty out of his head that would make him father of what is called fractal geometry.
Today, at 84, he's a retired Sterling Professor from Yale but is still getting awards thrown his way and even planets named after him. I thought I'd make something to mark his birthday since I've been playing a bit with fractals and JavaScript lately and because he's just damn cool.
If you haven't already, check out the minimized sub-128 bytes Mandelbrot as well as the prettier and fancier Canvas fractal renderer to see the previous Mandelbrot related posts.
If you want to read more about the Mandelbrot set and fractals in general, I suggest you hit up Wikipedia (lots of juicy math!). What it comes down to, though, is that very simple formulas can produce the most fascinating, infinitely complex structures which in turn can be made into pretty pictures on a computer.
So, what I've spent my morning doing is hacking together my fractal renderer with some of the Flickr stuff I've also been doing. Instead of drawing colored pixels, it now pulls in a (limited) number of Flickr images and uses those to paint a visualization of the Mandelbrot set.
You can add a parameter to the url to search for a specific query at Flickr, ie. ".../flickrbrot/?puppies", although the images are painted so small it's pretty hard to discern what they really are. Searching for a specific color can sometimes produce a nicer looking result, ie. "?orange" or "?purple".
Only Firefox, Opera and Webkit nightly!
Check it out here.
Suggested listening: Jonathan Coulton - Mandelbrot Set
Read more...
A Digg-'em-up struggle against the overwhelming forces of social media.
Impatient? Click to play Digg Attack! (read the intro screen for instructions) or keep reading for details and background.
This is something I started a good while ago but only just recently got into a playable state. The goal was to create a small game where the action is based on an external data source. It turns out that the Digg API fits that bill fine as it provides both varied data and a steady stream of it, and thus the product, in its current state, is an unusual 2D shooter where the flow of enemies is based on stories that are "dugg".
The protagonists come in the form of a small flock of social media heroes, controlled by targets set by the player and influenced by various objects on the map. They are also somewhat autonomous as they use simple flocking mechanisms to stay close together and move as a group.
With the exception of the music, it uses only the Canvas element and regular DHTML and another goal was that I wanted it to feel "fluid" and be able to compete with similar Flash games, even when there was a lot going on on the screen. I think it meets this goal just fine, at least when played on a moderately sized box. I also know there are some decent optimizations to be done in there once I get around to it (ie. the explosions could be prerendered rather than dynamically created as they are now, etc.) On the sound side there is currently only background music. I had some sound effects going on with SoundManager2, but it's giving me a bit of trouble, so I've sort of abandoned them for now. Also, apart from the vortex sprite and the prerendered text, all the graphics are created at runtime with Canvas drawing.
The music is by friend_kami and brainworks, all released under Creative Commons licenses and found at SectionZ.
Ok, get on with it!
You start each level with a number of heroes (ie. little blueish dudes). The game connects to Digg.com and as stories are dugg, enemies are spawned and enter the screen from either the left or the right side. The type and number of enemies spawned depend on how many diggs the story has received:
6-50 diggs: Antiheroes, similar to your heroes, but red (and evil!) Spawn in flocks of 2-7 antiheroes. These guys are small and weak but will nevertheless actively and tirelessly hunt your heroes.
51-500 diggs: Predators, larger and more dangerous. Coming in packs of 1-3 predators, these also actively hunt your heroes but are easier to out maneuver. Their larger size more than makes up for this, however.
501-infinity diggs: Biggies. Huge, slow and not very bright. These enemies wander around with no aim, just bouncing about the level. Are tougher to kill than the others, but move slowly.
The goal is to survive - or at least try to - for a number of seconds (typically 60-120) before you autmatically proceed to the next level. If you are so unfortunate as to lose all your heroes (chances are good that you will), reinforcements will be sent in at the low, low cost of 25% of your currently accumulated score.
Don't worry if you keep dying almost immediately, just try again and the next round might be more forgiving. The difficulty varies in time due to the unpredictable nature of the data the enemies are based on. You might be unfortunate and run into a stream of high/medium profile diggs and be flooded with strong enemies, or you might be able to just cut your way through small groups of antiheroes for most of the level.
The levels
As each level has a fixed amount of time, the ultimate goal is to get the highest score by the end of the last level. At present time there are a total of 12 levels with a combined game time of 15 minutes and 10 seconds.The first level is just an empty playing field. Later levels feature blocking structures, attractors/deflectors, zappers and even small black holes. Here's a quick overview of what you could be facing:
Blocks: These are simple impassable structures that block your path and/or divide the map in smaller sections.
Directors: When you come in the range of a director, your heroes will feel a sudden urge to move in the direction of the arrow. They come in 4 flavours: up, down, left and right.
Attractors: Much like the directors, these also affect your heroes' senses of direction but rather than make them move in a specific direction, your heroes are compelled to move towards the center of the attractor. Be careful as it can be hard to escape once you've become trapped.
Repulsors: The twin sibling of the attractor, the repulsor does the exact opposite and make your heroes move away from the point of repulsor.
Zapper: High powered electrical menaces that make short work of your magnificent heroes. Come within range of one of these bad boys and one of your heroes is sure to be toast. Fortunately it takes a second before the zapper is ready again.
Vortex: Gravitational pull will drag your heroes to the midst of these miniature black holes where nothing and everything meet and the very fabric of spacetime is torn apart (that includes your heroes).
Except for the walls and blocks, the enemies are not affected by any of these map objects.
Quick tips
- The enemies go for the collective (average) center of your heroes. You can exploit this by spreading your heroes out over the entire map.
- Even if you can't move through blocks, you can still shoot through them.
Mostly tested in Firefox 3 but looks to be working in Opera 9.6 and Safari as well. If you get graphical glitches in Safari, try with a recent WebKit nightly. IE is of course a no go.
So, there are still a bunch of outstanding issues and stuff, but mostly it plays well. Actually, I'm not entirely satisfied with the gameplay yet and would like to evolve it a bit but I'm not sure in what direction. The whole "external data" part is up in the air as well. If you have any suggestions for changes, bug reports :( or just want to comment, please do so below. And post some high scores, even if you don't bother finishing all 12 levels!
There have been reports of issues with Linux and I think it might be related to nVidia cards, so if you're having problems with Linux and have a non-nVidia card, please leave a comment below.
The general rules and the details about how to control your heroes are described on the intro screen, so make sure you read it.
Click to play Digg Attack!
And if you like it, why don't you...