Archive for the ‘Development’ Category
nofollow Bookmarklet
Here is a smallish bookmarklet that highlights all links that are marked with the nofollow attribute. Just drag and drop it to your bookmarks bar.
In its current version the bookmarklet is very very simple: it just highlights nofollow-links and reports back the total number. However it only works on frameless documents.
Here’s the code in a readable <code>-block:
-
javascript:(function(){
-
for (var i = 0, a = document.getElementsByTagName('a'), b = a.length, c = b; i < b; i++) {
-
a[i].rel.match(/nofollow/i) ? a[i].style.backgroundColor = '#ff0066' : c–;
-
}
-
alert(c);
-
})();
That’s the shortest I could get. Have fun :).
P.S. You can test-drive it right away on this page: the about-link in the footer is a nofollow-link.
P.P.S. It’s the browser that turns a double minus into a single long dash.
Unobtrusive Smilies :)
I don’t know whether you may find use for this, it might be a complete overhaul, but anyway.
Smilies are small inline images that represent a mood like being sad :( or help enrich the context with some emotion like winking after a joke ;). Everybody uses them but no one actually puts down those img-tags: we rely on our smart CMS’s to the job. Smilies are accessible since screen readers use either the title or the alternative text attributes of the img-tag. The problem is that such inline images aren’t semantically correct: they should be part of the text as text and not as images.
I’ve put down a small (~2KB minified) mixture which filters all smilies and replaces them with images in an unobtrusive way.
What is the basic?
Default behavior is to query the document for span-tags that have the class smiley. Each one option is customizable.
What’s the compatibility?
It’s known to work with Firefox 2, Firefox 3, IE5.5, IE6, IE7, Safari 3 and Opera 9 under Windows, Safari 3 under Mac OS X and Konqueror 3.5 under Kubuntu.
How to trigger it?
Use it just as any other unobtrusive JavaScript out there:
-
window.onload = function() {
-
uns.parse();
-
};
Or gain performance by providing a node where smilies are to be found, like the main content div-block:
-
window.onload = function() {
-
uns.parse({node: document.getElementById('content')});
-
};
You can also provide an onfinish callback:
-
window.onload = function() {
-
uns.parse({
-
node: document.getElementById('content'),
-
onfinish: function() {
-
alert('finished');
-
}
-
});
-
};
Or you can add additional smilies:
-
window.onload = function() {
-
uns.smilies({
-
':cska:': 'images/cska.gif'
-
});
-
uns.parse();
-
};
You can also AJAX load new content into some poor div and run the parser afterwards:
-
xhr.onreadystatechange = function() {
-
if (xhr.readyState == 4) {
-
var comments = document.getElementById('comments');
-
comments.innerHtml = xhr.responseText;
-
uns.parse({node: comments});
-
}
-
};
Where can it be seen?
I’ve put down a small demo.
Log
20.02.2008: 0.1 Initial release.
22.02.2008: 0.2 Added support for native getElementsByClassName and tested with Firefox 3, added support for IE5.5 and IE6.
TOCoholic
I’ve had the other day some referrers from a site listing a bunch of WordPress plugins about TOCoholic. So I decided to dig it out. Here it is:
What’s new about the plugin? Nothing. I’ve just dropped it in the plugins directory and … it worked. This tells me two things:
- WordPress’ developers had made some nice efforts to make it backwards compatible and this is great, kudos
- I’ve been more than a decent developer 18 months ago :roll:
I have plans to make some changes to plugin’s features and to optimize it a bit, but for now it’s fine just as it is. So stay tuned.

