I'm a beginner in learning JavaScript and am in need of some advanced
expertise.
I'm using the ForEachTiddler plugin to generate a list book titles.
The book titles are entered as the titles of the tiddlers.
The current display of a large volume of initial articles is annoying:
to many A's, An's and The's.
Searching around I found a bit of Javascript someone cooked up to
address this issue within the context of an online library catalog:
"I have updated the script to ignore initial articles. I updated the
sort_alpha function thusly:
sort_alpha: function(a,b) {
if (a[0].substring(0,2) == "A ") {
a[0] = a[0].substring(2,a[0].length);
}
if (b[0].substring(0,2) == "A ") {
b[0] = b[0].substring(2,b[0].length);
}
if (a[0].substring(0,3) == "An ") {
a[0] = a[0].substring(3,a[0].length);
}
if (b[0].substring(0,3) == "An ") {
b[0] = b[0].substring(3,b[0].length);
}
if (a[0].substring(0,4) == "The ") {
a[0] = a[0].substring(4,a[0].length);
}
if (b[0].substring(0,4) == "The ") {
b[0] = b[0].substring(4,b[0].length);
}
if (a[0].toUpperCase()==b[0].toUpperCase()) return 0;
if (a[0].toUpperCase()<b[0].toUpperCase()) return -1;
return 1;
},
They state: "There are probably more elegant ways to do this but I'm a
real hack when it comes to javascript! ;)"
From:
http://www.innopacusers.org/list/archives/2007/msg07085.html
Is there an elegant way to include such a script with a FET macro
call?
Thanks in advance,
Mark