-
"So you want a facebox that shows a form which does an asynchronous submission and updates the facebox with the results of the submission showing error or success messages." Yes, I do. This worked. Thanks, Wes Gibbs.
-
It's a guide to Dudley in SSF4. Looks like a good one, and, given it's a few years since I've played Dudley (and that was in a different game)… much welcome. To read in the near future.
-
"Ben O'Steen's talk from OKFN; lots of nice little things in here about preserving data and opening it up into a variety of forms."
-
"Lazy loader is a jQuery plugin written in JavaScript. It delays loading of images in (long) web pages. Images outside of viewport (visible part of web page) wont be loaded before user scrolls to them." Handy.
-
"Jcrop is the quick and easy way to add image cropping functionality to your web application. It combines the ease-of-use of a typical jQuery plugin with a powerful cross-platform DHTML cropping engine that is faithful to familiar desktop graphics applications." Wow – snappy, well-made, and very impressive.
-
"Slammer gives you any grid you want, anywhere you want: Typographic Grids, Golden Sections, Fibonacci series or Rule of Thirds. Thats not all, Slammer also has Rulers, Crosshairs, Magnifier, Measurements & Screenshots. Slammer is a must have for any designer."
-
Bleak, stylistically lovely, flash game about the drudgery of existence. Not cheery, but some beautiful touches. And I loved the cow.
-
"Welcome to the home of the Generic Syntax Highlighter – GeSHi. GeSHi started as an idea to create a generic syntax highlighter for the phpBB forum system, but has been generalised to this project." As seen on the Panic blog: very impressive, in particular, the clickable documentation of Objective-C keywords.
-
"Michael Abrash's classic Graphics Programming Black Book is a compilation of Michael's previous writings on assembly language and graphics programming (including from his "Graphics Programming" column in Dr. Dobb's Journal). Much of the focus of this book is on profiling and code testing, as well as performance optimization. It also explores much of the technology behind the Doom and Quake 3-D games, and 3-D graphics problems such as texture mapping, hidden surface removal, and the like." My old URL for this no longer works, but fortunately, this one does.
-
"The commercial worked on Lucas but a few years later, the computer graphics group at ILM was sold by Lucas to Steve Jobs for $5 million and became Pixar. Loren Carpenter is still at Pixar today; he's the company's Chief Scientist." Marvellous.
-
"slideViewer (a jQuery image slider built on a single unordered list)". Which looks nifty.
-
"Flicking over to the old graphics — and I, for one, found it almost impossible not to do so on every screen — shows you the game as you originally experienced it, and it looks completely different. Suddenly you remember the old imagery too. Conceptual memory gives way to visual memory, in a clear illustration of how the mind functions on different levels. It’s an odd experience, first thinking you recognise something, then discovering that the original was in fact quite different, but that you now remember that too, as additional detail. In one way it’s a contradiction, and in another it’s sharper focus." Emmett on the Monkey Island remake, and the ability to dynamically swap between old and new interfaces.
-
"This jQuery plugin generates sparklines (small inline charts) directly in the browser using data supplied either inline in the HTML, or via javascript." Nifty.
-
"…when we step into the shoes of that avatar, be it 1st-person, 3rd-person or otherwise, we exit the darkened movie theater paradigm and enter an intricate, performative, exploratory lab of untested ideas and speculation. We enter a playful space that feels and responds much more like a live theater rehearsal than an interactive movie or a triggered series of movie clips." Michael debunks the games-as-cinema analogy with an interesting take that considers them as more like theatre rehearsal.
-
"This is not a book about the VCS, nor breakout, nor video games and video game culture; it is a chronicle of the experience of that entity we might call “the player.” Oddly, there is little I can take from it in terms of approaches to video gaming or thoughts on the VCS Breakout. But it did enlarge my perspective and help me think about physiological, cognitive, and, let us say, monomaniacal aspects of video game play. Nervous, very dreadfully nervous Sudnow has been, but why would I say that he is mad?" Sudnow passed away very recently; I really ought to read his book, more than ever.
-
"[s3fm]… lets anyone run a streaming radio station, with just a folder of MP3s. Put those MP3s in an Amazon S3 bucket, and give your friends the S3 FM link."
-
Matt's talk (in English) from Lift 09, on scientific fiction, stories, and the design process. Good stuff – not too long – and wonderfully filmed: the cameraman focuses on his hands as much as his face, which is just perfect.
-
NeoGAF users band together to make a perfect, eight-stage, LittleBigPlanet rendition of Contra. Remarkable, especially the behind-the-backdrop puppeteering that makes the walking-into-the-screen levels possible. This had better not get a takedown slapped on it, because it's phenomenal.
-
"Perfect gift for any World of Warcraft player or other MMORPGer in general. You get one "main" glass and one "alt" glass. Serving idea: fill your main with your alcoholic beverage and your alt with your chaser since mains are typically stronger than alts." Oh dear. (But: good gag, and dangerous for drinking games).
-
"SFZero is a Collaborative Production Game. Players build characters by completing tasks for their groups and increasing their Score. The goals of play include meeting new people, exploring the city, and participating in non-consumer leisure activities."
-
"One of my enduring passions is exploring graphic design with programmatic and generative systems. While some aspects of design require the skilled hand of the designer, others can be formalized and explored by computer. For those tasks, Mathematica is an exceptional tool." Some lovely thinking around generative design.
-
That's sad; he was a fount of statistics since I first listened to TMS, and long before that.
-
"By wrapping and extending Flash 8's sound API, SoundManager 2 brings solid audio functionality to Javascript." Dark voodoo. Dark, clever, voodoo.
-
This was actually a pretty good tutorial for the jQuery UI Slider control, if only for illustrating how much code – notably markup/styles – you have to provide before the slider works.
-
Kyle Gabler of 2D Boy gives the first Global Game Jam keynote. Seven minutes, seven tips, packed with goodness. He's not wrong.
-
"I’m much more interested in automated nostalgia than automated presence – data feeds that gradually acrue in your wake, rather than constantly dragging your focus on to the next five minutes." Yes.
-
Because I've never known how to spell it until now, and it's one of my favourite words.
-
Very beautiful, and, so far, very sensible implementation of touch interactions. Looking forward to playing much more of this over the holidays.
-
"Tears shouldn’t be our goal. Stories don’t need to be our tools. The majority of art forms don’t rely on narrative for their emotional impact. Stop and think about that for a second. The games industry tends to draw on such an amazingly limited roster of inspirations that it’s easy to forget it. But our obsession with linear, story-based – word-based, even – non-participatory art at the expense of all the other forms makes life so much harder for games, and it makes me crazy."
-
"Modern day awesominers know there are actually 118 fundamental "awesoments" that compose all good things. The Periodic table of Awesoments can be a very useful tool. It's designed to show the relationships between awesoments, and often one can even predict how awesoments interact simply by their positions on the table."
-
Very good – some good stuff around how the library works, but also lots of basics around how to optimise Javascript.
-
Gerard Way reviews Left 4 Dead on My Chemical Romance's (totally excellent) blog.
-
"Left 4 Dead is out
Friends kill zombies together
Is it worth getting?"
Yes Gerard, it is. -
"If you want a recipe for restless sleep, I can give you one. Add one part “what will my wife think” with 3,000 parts Benjamin Franklin; stir in a “beer anytime you damn well please” and top with a chance at financial independence."
-
"These concepts are not complicated by Cern standards. We are entering a zone which is weaponised to boggle."
-
Simple, straightforward, pretty much correct.
-
Yes, this is going to come in handy.
-
"This javascript function can then read in the current content of the text area, format it using a trimmed down version of textile, and then set the content of a DIV with the resulting HTML. The end result of all this is live comment preview, with textile formatting." Live textile preview functionality.
-
"Trying to over-explain the cause of a disaster often detracts from its more tangible impact. … Instead, Faliszek says, it is more effective to create resonant gameplay experiences that players will remember, particularly if the setting in question, such as a zombie invasion (or a tornado outbreak, for that matter) is already familiar." Why games don't always need tangible villains.
-
A nice approach to doing some of the typical monitoring you'd want to do with Google Analytics, eg monitoring PDF downloads. I'm not totally convinced by some of his syntax, but the functionality is good, and the regex trick is nice.
-
"It's just an Nintendo in a toaster, but I like it."
-
A strong article from Joe on some guidelines, based on experience, for writing RSpec user stories.
-
Getting around the issues with Rails' authenticity tokens and trying to perform Ajax requests in jQuery.
-
"I think this is very important. If we limit ourselves to only designing the present then the ‘future’ will just happen to us, and the one we get will be driven by technology and economics. We need to develop ways of speculating that are grounded in fact yet engage the imagination and allow us to debate different possible futures before they happen." Interesting interview with Dunne over at the Adobe site.
-
Fingerboarding game for the iPod; really delightful, and clearly a fun thing to do with your fingers. Also: it makes sense to play this with the device on a flat surface, which is unusual for the iPod games released to date.
-
"The winner is Tim Graham who took manual personal data collection to another level. From email spam, to beverage consumption, to aches and pains, Tim embraced the spirit of self-surveillance. He even made his personal data available in the forums." Dataviz overload!
-
"What are the weird, seemingly unimportant data that can join up the areas we already know, and how do we know where to look for it? In order to be truly useful eyes on the street, we need to be able to take the scenic route, or shortcuts, or any other route that will be fun or illuminating for us and the people we speak to."
jQuery: passing elements to event handlers
03 August 2007
It’s fairly common practice in jQuery to bind events to a quick anonymous function that performs the action you desire. But how do you bind an event to a non-anonymous function – something that you’ve already extracted into a function so as to avoid reptition? I learned this one the hard way, and thought it was worth sharing.
I was working on some jQuery to apply to some legacy HTML at work, and was fiddling around to see if our goal was possible.
I was working on a “springy” archive menu. There are some headers and some lists; the lists are hidden on pageload, and when you click on a header, the subsequent list (ie the archive for that year) opens. Many lists can be open or closed at once. In addition, we toggle a class on the header (rather than the header link, which is there purely out of legacy code for now) to change an image, indicating that it’s open.
Here’s my proof of concept code – my first working version to demonstrate how this functionality would work.
$(document).ready(function() {
var headlinks = $("div.container h3 a");
for (var i=0; i < headlinks.length; i++) {
$(headlinks[i]).bind("click", function() {
$(this).parent().next().toggle();
$(this).parent().toggleClass("open");
});
$(headlinks[i]).parent().next().toggle();
$(headlinks[i]).parent().toggleClass("open");
};
toggleArchiveLinks(headlinks[0]);
$(headlinks[0]).parent().next().toggle();
$(headlinks[0]).parent().toggleClass("open");
});
Now we've got the code working, it's time to refactor. There's a lot of repetition going on - three instances of that "toggle visibility and toggle class" behaviour, so let's pull that out into a function:
function toggleArchiveLinks(element) {
$(element).parent().next().toggle();
$(element).parent().toggleClass("open");
return false;
}
Much better. Unfortunately, we can't replace our anonymous function within that bind
directive with this. I initially thought you could bind "click" to toggleArchiveLinks(this)
. But that doesn't work, because in the context of events, what gets passed out to another function is the event object itself. (I think it works fine in the anonymous object due to the way things are scoped).
But it's a bit ugly to refactor some, but not all of the code. After looking at the jQuery docs for bind
, it turns out that there's a third parameter you can pass in: a data object. This is made available to a handler function. So that means we can pass information about the element we want to toggle to a handler event. We write our new bind directive like this:
$(headlinks[i]).bind("click", {element: headlinks[i]}, handleToggleEvent);
That object in the middle will be made available to a new function handleToggleEvent
. (We could, of course, pass as many key/value pairs as we wanted to to the function). We also need to write handleToggleEvent
. That function looks like this:
function handleToggleEvent(event) {
toggleArchiveLinks(event.data.element);
event.preventDefault();
}
The function accepts an event as a parameter, and the object/hash from our bind
statement is available as event.data
. We're then free to call toggleArchiveLinks
on the element of our choosing. Finally, we have to call event.preventDefault
in order to stop the event propagating any further. If we don't do this, the bound behaviour will happen, and then the link will click through as normal. return false;
won't work here, because we're actually dealing with the event itself, not just an anonymous function.
So we've now managed to refactor some repetitive code and call it from a bind
statement. Our final jQuery script looks like this:
$(document).ready(function() {
var headlinks = $("div.container h3 a");
for (var i=0; i < headlinks.length; i++) {
$(headlinks[i]).bind("click", {element: headlinks[i]}, handleToggleEvent);
toggleArchiveLinks(headlinks[i]);
};
toggleArchiveLinks(headlinks[0]);
});
function toggleArchiveLinks(element) {
$(element).parent().next().toggle();
$(element).parent().toggleClass("open");
return false;
}
function handleToggleEvent(event) {
toggleArchiveLinks(event.data.element);
event.preventDefault();
}
Which is much better, I think.