Just thought I'd share this for anyone who's interested...
>>> "
http://www.google.com/search?source=ig&hl=en&rlz=&q=a+really+long+url&aq=f&oq=&aqi=g10
".smush()
"http://www.google....rl&aq=f&oq=&aqi=g10"
-----------
Object.extend(String.prototype, (function() {
function smush(length, truncation) {
length = length || 40;
truncation = Object.isUndefined(truncation) ? '...' : truncation;
var chunkLength = (length - truncation.length) / 2;
return this.length > length ?
this.slice(0, Math.floor(chunkLength)) + truncation +
this.slice(this.length - Math.ceil(chunkLength)) : String(this);
}
return {
smush: smush
}
})());
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---