Post by Peter on Apr 29, 2005 17:04:44 GMT
Felt like doing a code ...
This will alphabetise threads on the page you are viewing. It will ignore sticky threads.
Board footers...
<script type="text/javascript">
<!--
// Alphabetise Threads
// Created by Peter
// Array of icons, change them if needed
var icons = [
"sticky.gif",
"poll_icon.gif",
"poll_icon_closed.gif",
"stickylock.gif"
];
var pollRow = {
got: null,
poll: 0
};
function alphaThreads(){
var iAlp = [];
var iLetter = iPRow = "";
var re1 = new RegExp(icons[0] + "|" + icons[3]);
var iTable = document.getElementsByTagName("table");
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).cellPadding == "4" && iTable.item(t).cellSpacing == "1"){
if(iTable.item(t).rows.item(0).cells.item(0).className == "catbg"){
var iRow = iTable.item(t).getElementsByTagName("tr");
for(r = (iRow.length - 1); r > 0; r --){
if(iRow.item(r).cells.item(0).className == "windowbg2"){
if(iRow.item(r).cells.item(0).firstChild.src.match(re1)){
continue;
}
var re3 = new RegExp(icons[1] + "|" + icons[2]);
if(iRow.item(r).cells.item(0).firstChild.src.match(re3)){
if(iRow.item(r - 1).cells.item(0).firstChild.src.match(re1)){
continue;
}
}
var re2 = new RegExp(icons[1] + "|" + icons[2]);
if(iRow.item(r).cells.item(0).firstChild.src.match(re2)){
if(!iRow.item(r - 1).cells.item(1).firstChild.src.match(re1)){
if(iRow.item(r - 1).cells.item(1).rowSpan == "2"){
iRow.item(r).insertCell(iRow.item(r).cells.length)
pollRow.got = iRow.item(r).cells.item(0).cloneNode(true);
iRow.item(r).parentNode.removeChild(iRow.item(r));
pollRow.poll = 1;
continue;
} else {
pollRow.poll = 0;
}
}
}
if(iRow.item(r).getElementsByTagName("b").item(0)){
iPRow = (pollRow.poll == 1)? "{-poll-}" : "";
iLetter = iRow.item(r).getElementsByTagName("b").item(0).innerHTML.substr(0,1) + iPRow;
}
if(iRow.item(r) && !iRow.item(r).cells.item(0).firstChild.src.match(re3)){
iAlp.push([iLetter.toLowerCase(), iRow.item(r).cloneNode(true)]);
iRow.item(r).parentNode.removeChild(iRow.item(r));
pollRow.poll = 0;
}
}
}
iTable.item(t).id = "alphathreads";
}
}
}
iAlp.sort();
for(a = 0; a < iAlp.length; a ++){
var iNum = (document.all)? 0 : 1;
document.getElementById("alphathreads").childNodes[iNum].appendChild(iAlp[1]);
if(pollRow.got != null && iAlp[0].match(/\{-poll-\}/)){
var nRow = document.createElement("tr");
nRow.appendChild(pollRow.got.cloneNode(true));
document.getElementById("alphathreads").childNodes[iNum].appendChild(nRow);
}
}
}
if(!location.href.match(/action=(display|post|modify)/i)){
alphaThreads();
}
//-->
</script>
Cross browser, as always
This will alphabetise threads on the page you are viewing. It will ignore sticky threads.
Board footers...
<script type="text/javascript">
<!--
// Alphabetise Threads
// Created by Peter
// Array of icons, change them if needed
var icons = [
"sticky.gif",
"poll_icon.gif",
"poll_icon_closed.gif",
"stickylock.gif"
];
var pollRow = {
got: null,
poll: 0
};
function alphaThreads(){
var iAlp = [];
var iLetter = iPRow = "";
var re1 = new RegExp(icons[0] + "|" + icons[3]);
var iTable = document.getElementsByTagName("table");
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).cellPadding == "4" && iTable.item(t).cellSpacing == "1"){
if(iTable.item(t).rows.item(0).cells.item(0).className == "catbg"){
var iRow = iTable.item(t).getElementsByTagName("tr");
for(r = (iRow.length - 1); r > 0; r --){
if(iRow.item(r).cells.item(0).className == "windowbg2"){
if(iRow.item(r).cells.item(0).firstChild.src.match(re1)){
continue;
}
var re3 = new RegExp(icons[1] + "|" + icons[2]);
if(iRow.item(r).cells.item(0).firstChild.src.match(re3)){
if(iRow.item(r - 1).cells.item(0).firstChild.src.match(re1)){
continue;
}
}
var re2 = new RegExp(icons[1] + "|" + icons[2]);
if(iRow.item(r).cells.item(0).firstChild.src.match(re2)){
if(!iRow.item(r - 1).cells.item(1).firstChild.src.match(re1)){
if(iRow.item(r - 1).cells.item(1).rowSpan == "2"){
iRow.item(r).insertCell(iRow.item(r).cells.length)
pollRow.got = iRow.item(r).cells.item(0).cloneNode(true);
iRow.item(r).parentNode.removeChild(iRow.item(r));
pollRow.poll = 1;
continue;
} else {
pollRow.poll = 0;
}
}
}
if(iRow.item(r).getElementsByTagName("b").item(0)){
iPRow = (pollRow.poll == 1)? "{-poll-}" : "";
iLetter = iRow.item(r).getElementsByTagName("b").item(0).innerHTML.substr(0,1) + iPRow;
}
if(iRow.item(r) && !iRow.item(r).cells.item(0).firstChild.src.match(re3)){
iAlp.push([iLetter.toLowerCase(), iRow.item(r).cloneNode(true)]);
iRow.item(r).parentNode.removeChild(iRow.item(r));
pollRow.poll = 0;
}
}
}
iTable.item(t).id = "alphathreads";
}
}
}
iAlp.sort();
for(a = 0; a < iAlp.length; a ++){
var iNum = (document.all)? 0 : 1;
document.getElementById("alphathreads").childNodes[iNum].appendChild(iAlp[1]);
if(pollRow.got != null && iAlp[0].match(/\{-poll-\}/)){
var nRow = document.createElement("tr");
nRow.appendChild(pollRow.got.cloneNode(true));
document.getElementById("alphathreads").childNodes[iNum].appendChild(nRow);
}
}
}
if(!location.href.match(/action=(display|post|modify)/i)){
alphaThreads();
}
//-->
</script>
Cross browser, as always