sephlaire
01-26-2012, 04:10 PM
I still working on this script for sorting fields in a wiki and have ran into another feature I'm trying to get working.
Right now I have a long list that needs to be sorted and it looks like this:
[[wiki:software:softwarename|Display Text]]
[[wiki:somethingelse:alphaname|Alpha Text]]
[[wiki:whoops:etchers|Elephants]]
The first part of my code is an attempt to match those with a regular expression:
else if (text.match(/\[\[(.*):(.*)\]\]/)) {
return sorttable.sort_link;
}
The second part is the actual sorting:
sort_link: function(a,b) {
aa = a[0].split(":",4);
bb = b[0].split(":",4);
if (aa[3]==bb[3]) {return 0;}
if (aa[3]<bb[3]) {return -1;}
return 1;
},
I'm pretty sure the regular expression works... at least it works on some regular expression "testings" websites. But I just cant get these links to sort. I am trying to wort by the Display text which is located after the '|' in the text.
Right now I have a long list that needs to be sorted and it looks like this:
[[wiki:software:softwarename|Display Text]]
[[wiki:somethingelse:alphaname|Alpha Text]]
[[wiki:whoops:etchers|Elephants]]
The first part of my code is an attempt to match those with a regular expression:
else if (text.match(/\[\[(.*):(.*)\]\]/)) {
return sorttable.sort_link;
}
The second part is the actual sorting:
sort_link: function(a,b) {
aa = a[0].split(":",4);
bb = b[0].split(":",4);
if (aa[3]==bb[3]) {return 0;}
if (aa[3]<bb[3]) {return -1;}
return 1;
},
I'm pretty sure the regular expression works... at least it works on some regular expression "testings" websites. But I just cant get these links to sort. I am trying to wort by the Display text which is located after the '|' in the text.