Code tutorials for lazy people with Ajax Code Display
Currently I am writing a lot of tutorials for an online self-training course about web standards and I ran into the annoyance of having to maintain example code in two places: the code itself and the HTML document with the explanations. Therefore I took jQuery and wrote a small script that automatically turns links to HTML code examples with HTML entities and line numbers. You can define which lines to display, which lines should be highlighted and you can add a live preview in an IFRAME when the link is clicked.
- Check out Ajax Code Display
Tags: ajax, annoyances, code, codehighlighting, javascript, tutorials


January 28th, 2008 at 6:22 pm
Very nice. Out of curiosity, how come you used jQuery and not YUI?
January 28th, 2008 at 7:20 pm
Because jQuery is better…?
I’d argue that you’d have less typing and faster development with jQuery, but as someone familiar with YUI, I’d love to hear the answer to this question.
January 28th, 2008 at 9:50 pm
The reason was actually circumstances: I wrote this on my eeePC in Kate on Linux and I hadn’t gotten the localhost to run yet. As jQuery’s ajax works nicely with file:// and http:// I chose that.
I also said in my talk at @mediaAjax that it doesn’t matter what library you use unless you use one :)
I disagree with faster development though. Once you wrote in jQuery for a long time it might be the case, but personally I am confused with all the chaining and anonymous functions. I try to know my scope in my scripts and actually hate “this” as it is never unambiguous.
jQuery is a great piece of work, but I personally think it needs a lot of effort to write maintainable and clean code with it.
January 28th, 2008 at 10:06 pm
Thanks for replying. It is interesting in that a major bit of work we are doing now, I am actually using both jQuery and YUI – I have to admit I first found jQuery weird, but I really like it now.
YUI is more like what I would normally expect to be writing so that was quick to get going with.
The amount of time and code I have saved with jQuery though has really impressed me.
January 29th, 2008 at 5:36 pm
Hi,
I hope those tutorial will be helpful and user friendly. One ready you can submit them to a special section I’d provide and they will reach targeted audience.
January 29th, 2008 at 9:53 pm
I agree that chaining can be difficult to get used to, but it allows you to do so much more to be in a single line of code. You end up with expressive code that doesn’t rely on calling the object over and over again throughout the script to apply it’s properties/functions. If used wisely, each line of code defines an object’s actions and properties, without “scatterbraining” them throughout the script. That is only one, purely organizational benefit that I recognize every time I write a script. And the more I use jQuery, the more I realize that it has every bit of functionality that I need to get the job done.
January 29th, 2008 at 11:12 pm
Awesome stuff…I can definitely see using this. Thanks.
November 18th, 2009 at 7:22 am
Hi There,
It’s really very cool stuff.
I Tested it out using a simple *html, and it works great !!
however, i just couldn’t make it working when i tried to implement it in blog sites such as blogspot (http://liangtest.blogspot.com/2009/11/test.html)
I wonder can you please really help me on this, as I’m really out of ideas now.
:(
Thanks a thousand in advance…