Sunday, January 28, 2007

Is innerHTML an angel or the devil?

There are two faces of innerHTML.
On one hand, it’s proprietary. It's certainly not part of the W3C DOM specifications. It’s also not very robust. It takes a single argument - a string - and squeezes that into the element, regardless of whether the string contains well-formed markup or not. Heck, it doesn't even check if the markup has a closing tag, and is often the reason for baffling layout bugs. It is very dangerous compared to the standard DOM methods - createElement, createTextNode and appendChild.

On the other hand, innerHTML reduces the lines of code. It is easy to write, if you can stand the trouble of escaping characters in the string. It is very well-supported. In fact, it enjoys better cross-browser support that DOM methods don't have. It also is faster than DOM. This is a proven fact.

To use or not to use innerHTML...That's a definite toughie to answer!
I have to admit that I always have been tempted to use innerHTML through and through. I just can't stand the clumsy extra lines needed with DOM and all the variables declared.

It is much easier to use innerHTML when it comes to Ajax. It even is a part of a microformat - the AHAH.
It’s the simplest way of taking the responseText property of the XMLHttpRequest object and inserting it into a specified part of a page.
And it reduces the LOC (Lines of code) by at least 3 times.

innerHTML does look dirty. But there’s no way to make Ajax work without making some sort of trade-off with non-standard technologies.

Followers of the DOM standards would say not to follow innerHTML. As a programmer, even I shouldn't. innerHTML is a bad programming practice, just like using magic numbers in a piece of code. But I'm tempted. I think innerHTML makes my life easier. Only I have to be a little careful. I keep following innerHTML because, standard or not, innerHTML is gonna stay.

The confusion haunts me forever.

Saturday, January 27, 2007

Picodrive for 3rd edition.It’s almost the same 0.50 that’s available for S60 2nd edition

This is still a alpha version, and there’re problems to be fixed, like the alternate renderer.But it’s quite good for a first release.

Should work with all 3rd edition phones.If it doesn’t work with some game, try changing emulator settings

  • For a better performance, go to “Configure screen” and choose “portrait” mode.Also disable the three sound chips in “Configure sound”

  • If a game doesn’t work, or music is slow, go to “Configure screen” and choose a region manually rather than using “auto”


Download Picodrive For 3rd edition
http://phonesymbian.com/wp-content/uploads/2007/01/picodrive0_50_3rd.zip

So, after noodling around in beta in response to a reader's question about using Haloscan's new auto-import system with the new blogger, I was greeted with an arm-twisty hammerlock (I exaggerate for comic effect, of course!) in my old account and encouraged to make the move, thus Freshblog now resides in Beta.

Thursday, January 11, 2007

I was in the process of changing the template for my personal blog when I got this idea. I'm not sure whether anyone has already released this hack. Anyway, it is a very useful one.

We have seen several webpages where the sidebar blocks are alternating in style. (color, generally)
In websites, it is easy to do this by manually giving different classnames for alternate sidebar blocks. But this wouldn't be possible in Blogger, particularly because of the Drag-and-drop mechanism in Page Layout, which makes it difficult, because the owner has to change the class every time he repositions the widget. Also, it is tedious to add our custom code every time we add a new widget. After all, we are supposed to render ourselves indolent by making a one-time change to ease our work! ;)

So, is there a way to automate the alternating sidebar block styles? Sure there is!
Even I didn't expect it to be so simple a code when I started coding this.
If you want to see this hack in action, visit my test blog.

IMPLEMENTATION
1. Look for ]]></b:skin> tag in your template and copy this code just above that.

.even {
background-color: #EEEEEE;
}
.odd {
background-color: #AAAAAA;
}

This is where you make your customisations. Use whatever CSS you want to customise these two classes. I have just given background colors here.

2. Copy the following code just above the </head> tag.
<script src='http://bloggerhacked.googlepages.com/prototype.js' type='text/javascript'></script>
<script src='http://bloggerhacked.googlepages.com/evenodd.js' type='text/javascript'></script>


3. Save the template and you're done. That's neat and easy. :)

Note for advanced users: You might already be having prototype framework and addLoadEvent routine attached to your blog. In that case, feel free to take my Javascript file, modify it and host it in your preferred location.

Tuesday, January 9, 2007

Readers may be interested to know that the Scripted Re-Mark del.icio.us bookmarking utility has been updated. Previously launched on Freshblog, I've taken onboard the freedbacking therein and the re-hashed Scripted Re-Mark now sports the following features:

  • It works again. Yes, changes in the delicious interface crippled it. Sadly, I was travelling and unable to fix it. Thanks to those for pointing out the problem, and even better - the solution!

  • Supports functions-as-parameters. Strictly for the hard-core, this means you can now get it to operate on your titles, tags etc with JavaScript functions. Eg use toUpperCase() on your text. Or whatever you like. Dangerous in the wrong hands, please read the instructions. I'm curious to know what people will make of this.

  • Zip through. Faster operation since it will now only use that pesky del.icio.us-mandated delay on the bookmarks that it changes. If no rule changes the bookmark, it will jump straight to the next one without waiting. Now you can ruin your bookmarks even faster!

As always, I love getting comments so please send 'em in: horror stories, bugs, fixes, extensions, navel-gazing, use-cases - and especially your regexps and (shudder) functions.

*** Update ***

I've bolted more bells and whistles on to this power tool. It now supports tag stemming. Suppose you have similar tags like blog, blogging and blogs. Scripted Re-Mark can detect that these are similar (ie share a common stem, blog) and rename accordingly. Great for rationalising your tagspace, especially with plurals, tenses and the like.

There's also new support for a "touched tag" ie a tag that is added to all bookmarks that are updated. This is handy for multi-stage processing and manually reviewing edits.

I'm always looking out for more ideas, so please send them in!

*** UPDATE ***

Bowing to public pressure, Scripted Re-Mark now features a mass delete option. Wanna make some bookmarks drink the grape-flavoured Kool-Aid? Now you can ...

Please, be careful with this as it has the potential to inflict much sadness.

Filed in: , , , ,

Monday, January 8, 2007

This was a result of a sudden bulb which glowed in my head today morning. The current for the bulb was provided here. =) (Sorry that was a really bad joke)

Smileys sure increase the viewer experience, but don't they increase the writer experience too?
How often have you complained about enclosing text inside <b> and </b>, if you had to highlight something in your comment?

Well! You don't have to do that any more.
This hack is just for you. YOU decide how you want the experience to be in another blog; not the owner of that blog. (I admit that sentence was too farfetched! You need some leniency from the owner also. What if he doesn't let you comment? :-/ :D )

FUNCTIONALITY
This Greasemonkey script will add a few buttons in every blogger comments page that you visit, thus helping you to italicize, make bold or even add smileys to your comments.

It works closely with Smileys hack, but will work without that hack also.
If the original blog (the one where you are commenting) has the Smileys hack, it will show the smileys as little images. Otherwise, they will remain as smiley text. No problems!

You need Firefox with Greasemonkey installed to use this.

For those who don't know much about Greasemonkey: Please be aware that this script *will not* change the look of your blog. It will do nothing to your blog. A person can see the buttons only if he/she has the user script installed in his/her browser. So you cannot provide this as a feel-good feature to your readers. (You can recommend this to them, though. ;) )

But on the other hand, you can use this as a feel-good feature for yourself, in all blogger blogs. (you heard it right! All!)


INSTALLATION
1. Install Greasemonkey Extension in your Firefox browser.
2. Click on this link to get your user script.
3. You will get a popup to install the user script, which looks like this:
4. Click Install.


USAGE
This will work similar to most text editors.
Select some text, click the button for Bold; the selected text will be enclosed in <b> tags. Similarly for italics and links.
If you click on the smiley buttons, the equivalent text will be inserted. If the owner of the blog has installed the smiley hack, then it will be shown as images in the item page.



Note1: The smiley images won't show up in the comment page, even if the smiley hack is installed. So don't come complaining that they don't work.
Note2: Thanks to Aditya for hosting the images. :)

Update: The smiley images will show up in the comment page now. I have made a mod of Aditya's hack into my userscript to show them. If you have already installed my script, just uninstall and reinstall it from the link above in INSTALLATION step #2

Monday, January 1, 2007

A few ideas came to my mind when it was idle over the weekend. (An idle mind is the devil's workshop!!?? :D )

What are the limits to which we can tweak the blogger template? I can't say for sure. Too much of anything is bad. If we have to modify the entire architecture of the template, then it is not worth pursuing that hack.

Anyway, here are the ideas. Discussion is open.

Idea #1: Seamless Asynchronism in Navigation
Let me be specific. Is it worth implementing the entire post section in a custom manner, and getting rid of the GML portions altogether?
Right now, I can't think of any way other than that.
I stumbled upon a slider based asynchronous navigation in one website. We can use similar stuff for the older posts and newer posts links. Rather than bringing up the results in a freshly loaded page every time, we can just load the posts section. I reckon that will be a mammoth change.

The idea of seamless navigation encompasses any page inside a particular blog.
We can very well modify the blog to load only the post section every time. Why? Answer is simple; we seldom have sidebar sections which change with the type of page (Item, Index or Archive)

Idea #2: Search Suggest
Aditya had created the Native Search Suggest hack which he just showed a trailer of, but never released. I bet it was one of the most anticipated hacks, but Alas!

If you ask me, the idea of Google Suggest is one of the best AJAX implementations ever.

This idea is again something which I stumbled upon while experimenting with Firebug. I saw the response of the AJAX requests sent by Google Suggest, which was in a very desirable function call format.

When I typed "suggest", the HTTP request sent was

GET http://www.google.com/complete/search?hl=en&js=true&qu=suggest
And the response text was
sendRPCDone(frameElement, "suggest", new Array("suggest", "suggest link", ...
(Truncated, as it is too long)

So it is just a matter of defining the function, sendRPCDone. (i.e., deciding what the function does.)
But there is a catch here too. There is an inherent feature of Gecko-based browsers (don't know about others) where XMLHttpRequests (known to common man as AJAX, although there is more to AJAX than XMLHttpRequest) to other domains are not possible. So you cannot get the results in this case. Can we do this without XMLHttpRequest? This is something to be investigated.

So, Aditya, if you promise you'll release your Native Search Suggest soon, then there's no need to pursue the above one ;)

;;

By :
Free Blog Templates