Prototype
// Jun 28, 2006 - 21:26
Sylvain Zimmer has found a way of speeding up the $$-selector in Prototype.
According to Sylvain his code is up to 20 times faster and he has even set up a test page.
Prototype's current code is quite elegant (as always!) but very slow, so I wrote an add-on that makes this function up to 20 times faster in most usual cases (tested on IE6, Firefox 1.5 and Opera).
So if you are using the $$-selector download his alternative code from
his site.
trimpath
modifiers
// Jun 27, 2006 - 18:57
Thought I'd share two TrimPath template modifiers with you. Two very simple modifiers but still quite handy.
First is a newline to <br/> modifier which is the one I use the most.
"nl2br" : function(s) { return String(s).replace(/\n/g,"<br/>");}
The second one is a trim-function that strips whitespaces in the beginning and the end of a string. This one requires a external function called trimAll().
"trim" : function(s) { return trimAll(s);}
And the code for trimAll().
function trimAll(sString) {
while (sString.substring(0,1) == ' ') {
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ') {
sString = sString.substring(0,sString.length-1);
}
return sString;
}
To add the modifiers just add the lines of code in the TrimPath.parseTemplate_etc.modifierDef-section of the TrimPath-library. It should look something like this when you're done.
TrimPath.parseTemplate_etc.modifierDef = {
"eat":function(v) { return ""; },
"capitalize":function(s){ return String(s).toUpperCase(); },
"default":function(s, d) { return s != null ? s : d; },
"nl2br":function(s) { return String(s).replace(/\n/g,"<br/>");},
"trim":function(s) { return trimAll(s); }
}
Ajax
trimpath
JSON
// Jun 22, 2006 - 12:03
So all the hype is about AJAX, an acrynom every programmer is familiar with by now. However, I use AJAJ and I think most sites using AJAX really is using AJAJ.
So what is AJAJ then? Well, basically the same as AJAX but the last J stands for JSON. JSON has proven to be most users choice since it provides less overhead than XML. Personally I send raw JSON-encoded database resultsets with AJAX(J) and use TrimPath to get rid of manual DOM-tree manipulation. For those familiar with the Smarty template system, TrimPath is very easy to get started with.
Ajax
Flickr
// Jun 01, 2006 - 16:18
Did a simple Flickr-browser module today. It reads my public RSS-feed (Ajax of course) from Flickr and displays the thumbnails and you can move forwards and backwards in the feed.
Next I´m going to display some more information about the image and perhaps also make a grid and slideshow.
Why reinvent the wheel again, one might say? Because I can!