AJAXified live comment preview

Journal entry
June 14, 2005

Update: Ah well, it was a fun experiment, but I’ve decided to scrap it again, possible in favor of something pure Javascript’ish. The AJAX preview is either too unresponsive to be worthwhile or I send way too many requests against MT/MySQL that I am comfortable with on a shared server.

Thanks to the wonders of Sam Stephensons Prototype, Movable Types comment preview template and AJAX, I am now sporting live comment previews.

Go check it out.

There is an issue at the moment: It seems Movable Types comment preview doesn’t adhere to the settings I have set for stripping HTML, so some HTML elements might show up in the preview, but be stripped in the final comment. Bad, I know.

So far I’ve only got around to checking it in Firefox, but I think Prototype is my saviour here, and I assume the previews will work in all Javascript enabled browsers that support asynchronous XMLHTTPRequest - ie IE6, Firefox, Safari (I believe).

If you don’t have one of those browsers, well… What are you waiting for?

Categories
, ,
Selling out

Comments and Trackbacks

Jonathan Snook June 14, 2005

I’m finding the behaviour hit and miss. Firstly, it throws back an error message on occasion:

An error occurred: Bad ObjectDriver config: Connection error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)

Secondly, it just keeps blinking at me as I type. I don’t even want to think of how much bandwidth is being taken up by hitting the server each time I press a key.

Why not just leave this to javascript (besides a unified code-base for validation)?

Jonathan Snook June 14, 2005

And finally, linebreaks were retained in preview mode but weren’t upon posting. :)

Jakob S June 14, 2005

Heh, looks like I need to check what my MT comment settings are actually like. For starters, the automagic creation of linebreaks was disabled. That might also explain why the preview allows some HTML tags that I thought it didn’t.

As for bandwidth, I’ll have to keep an eye on that, but for what it’s worth it’s not sending a request on every keypress.

I actually had a pure Javascript implementation to begin with, but that didn’t take textformatting into account at all. Does anyone have a Textile Javascript implementation or something like it? ;)

Hmmm, I might be throwing too many requests at my backend with this. Might have to ditch it.

paul haine June 14, 2005

It’s pretty slow - it’s taking between 3 and 4 seconds between me stopping typing and updating the preview, so at first I thought it just wasn’t working at all…I just also glimpsed that MySQL error mentioned above but it went away of its own accord.

Nick July 6, 2005

I’m largely doing this just so I can test your live comment previews, but you might be interested to know that there is at least one JavaScript implementation of Textile. It’s been done in a number of ways (as described here) with the JavaScript code here.

Commenting on this entry has been closed.

... but if you're a dirty spambot, feel free to post a comment here anyways.