Tudor Barbu's blog

Ramblings about software development

09 Feb

Target blank links

Posted by Tudor. Tags: , ,

One never ending debate on the web is on whether external links should open in new windows. Some say Yes! they should open in new windows because we need to keep the users on our site as long as possible. Usually these are the sales/marketing people. The other group says No! They shouldn’t open in new windows, because they’re extremely annoying and we should always let the user decide. These are the programmers, the group I’m in.

There’s also a third player in the debate, the World Wide Web Consortium. According to the XHTML Strict specifications, the usage of the target attribute has been banned. This happens because the XHTML Strict standard focuses entirely on the content of the document while sending all the presentation data to the stylesheet. The target attribute is a presentational one, because it specifies how the data from the hypertext reference should be presented to the user (in a new window, in a frame and so on). The XHTML Strict standard is meant to be used with all kinds of user agents – not just browsers – even with those that don’t support data presentation in the traditional way, in a browser’s window. This category of user agents includes, but is not limited to, screen readers for visually impaired persons, text-based browser such as links, web crawlers and so on. How could a text-based browser open a link in a new window? It doesn’t even have the “new window” concept. Read the rest of this entry »

26 Jan

Semantic FAQs

Posted by Tudor. Tags: , ,

You know the saying it’s funny because is true? Well it also applies to software development. This drawing it’s funny because is true. And when – not if, when – your application will start looking like that, it’s obvious that you’ll need a FAQ section.

Usually, people use tables or other types of markup for setting up the FAQ page, but the proper way to code it is the long forgotten definition list. When it comes to semantics, this is the perfect choice. The questions in the FAQ represent the definition terms and their answers the definition data.

The proper xhtml code for the FAQ page should look like this…

<dl>
    <dt>How do I...?</dt>
    <dd>Just click the ... button!</dd>
    <dt>Are your sure?</dt>
    <dd>Positive!</dd>
</dl>

…of course, with more relevant data. Read the rest of this entry »

28 Dec

Javascript MVC

Posted by Tudor. Tags: , ,

Javascript Model View Controller

I’ve stumbled upon this javascript MVC framework. I didn’t quite get a good look at it, but it sound pretty promising and I’m going to experiment with it, as I’m a big fan of MVC frameworks.

So far I’ve used Zend Framework, CakePHP, looked over CodeIngiter and Symfony. Even tried Rails, but I didn’t like Ruby at all so I quit RoR after about 30 minutes. I consider MVC to be the best development pattern I’ve encountered so far. But I’ve always used it on the server side. Now I have the chance to see how MVC behaves on the client side.

I’m quite confident that this approach will save a lot of headaches, due to the separation of concerns. The thing I’m most excited with are the views, because all the cross-browser issues will most likely migrate here. And solving a small problem in IE 6 won’t jeopardize the rest of the application, by following the pattern we all know and hate – solve a bug, add 3 new ones in its place.

PS: this is just small talk, as I haven’t tried Javascript MVC so far…:P

28 Dec

Equal height divs

Posted by Tudor. Tags: , ,

Today’s topic, equal height columns. Back in the old days, when everybody was using tables, creating equal height columns was a piece of cake. The height of a table row – <tr> – and its cells was automatically changed to accommodate any amount of content. Nowadays, in our brand new Web2.0 world, people don’t use tables to set up the layout of a page. Everybody goes for CSS now. But using only CSS is pretty hard (to be read “almost impossible”) to set up a page where multiple columns have the same height. And it becomes even harder to do so when a column changes size (some hidden content is displayed). What then? Well, of course, javascript to the rescue. Read the rest of this entry »

19 Dec

Email antispam protection

Posted by Tudor. Tags: , ,

Spamming is by far the most idiotic of all computer related activities, and I doubt that there is a single person that din’t find junk mail in his/her inbox. But how do you get on a spammer list and most important, what can you do to prevent this? Read the rest of this entry »

Some time ago, I needed to find out if a DOM element is a descendant of another. A simple and elegant way to accomplish this is:

/**
 *
 * @param mixed granpa
 *
 */
Element.prototype.isDescendantOf = function( granpa ) {
	if ( typeof( granpa ) == 'string' ) {
		granpa = document.getElementById( granpa );
	}
	if ( !granpa ) {
		return false;
	}
	child = this;
	do {
		if (child == granpa ) {
			return true;
		}
		child = child.parentNode;
	}
	while ( child );
	return false;
}

…and afterwards…

var foo = document.getElementById( 'foo' );
var bar = document.getElementById( 'bar' );
if ( foo.isDescendantOf( bar ) ) {
	/* whatever */
}

Cool, isn’t it? Read the rest of this entry »