Post by Peter on Oct 1, 2005 13:55:37 GMT -8
This code will reorder the sub boards so that boards with newer posts will be at the top. Useful if you have a lot of sub boards in a board
Global footer.
<script type="text/javascript">
<!--
// Created by PopThosePringles
Date.prototype.stack = [];
Date.prototype.convert = function(y, m, d){
if(/^\D+$/.test(m)){
return new Date(m + " " + d + ", " + y).getMonth();
} else {
return (parseInt(m) - 1);
}
}
Date.prototype.toTimestamp = function(date, obj){
date[0] = (date[0].toString().length == 1)? "200" + date[0] : date[0];
date[1] = (typeof date[1] == "string")? this.convert(date[0], date[1], date[2]) : ((parseInt(date[1]) - 1));
date[4] = (date[4] > 12)? (date[4] - 12) : date[4];
this.stack.push([new Date(parseInt(date[0]), parseInt(date[1]), date[2], date[3], date[4], 0).getTime(), obj]);
this.stack.sort();
return this.stack.reverse();
}
function orderSBoards(){
var dRe = /((\w+|\d+)[\D])?(\d+)[thsndr\D]*(\d+)[,\s-\.\/at\s]*(\d+:\d+)(am|pm)?/mi;
var iCell = document.getElementsByTagName("td");
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).className == "windowbg2" && iCell.item(c).width == "24%"){
if(iCell.item(c).innerHTML.match(/(Today<\/b>|Yesterday) at (\d+:\d+)(am|pm)?/mi)){
var now = new Date();
var h = parseInt(RegExp.$2.split(":")[0]);
var mi = parseInt(RegExp.$2.split(":")[1]);
var d = (RegExp.$1.match(/Yesterday/i))? (now.getDate() - 1) : now.getDate();
if(RegExp.$3.match(/pm/i)){
h += 12;
}
new Date().toTimestamp([now.getFullYear(), (now.getMonth() + 1), d, h, mi], iCell.item(c).parentNode);
} else if(iCell.item(c).innerHTML.match(dRe)){
var d = parseInt(RegExp.$3);
var y = parseInt(RegExp.$4);
var h = parseInt(RegExp.$5.split(":")[0]);
var mi = parseInt(RegExp.$5.split(":")[1]);
var m = RegExp.$2;
if(RegExp.$6.match(/pm/i)){
h += 12;
}
new Date().toTimestamp([y, m, d, h, mi], iCell.item(c).parentNode);
} else {
new Date().toTimestamp([1000, 1, 1, 1, 1], iCell.item(c).parentNode);
}
iCell.item(c).parentNode.parentNode.id = "subboardstb";
iCell.item(c).parentNode.parentNode.removeChild(iCell.item(c).parentNode);
c --;
}
}
if(document.getElementById("subboardstb")){
var sbTB = document.getElementById("subboardstb");
for(s = 0; s < new Date().stack.length; s ++){
sbTB.appendChild(new Date().stack[1]);
}
}
}
if(location.href.match(/board=\w+/i)){
orderSBoards();
}
//-->
</script>
Global footer.
<script type="text/javascript">
<!--
// Created by PopThosePringles
Date.prototype.stack = [];
Date.prototype.convert = function(y, m, d){
if(/^\D+$/.test(m)){
return new Date(m + " " + d + ", " + y).getMonth();
} else {
return (parseInt(m) - 1);
}
}
Date.prototype.toTimestamp = function(date, obj){
date[0] = (date[0].toString().length == 1)? "200" + date[0] : date[0];
date[1] = (typeof date[1] == "string")? this.convert(date[0], date[1], date[2]) : ((parseInt(date[1]) - 1));
date[4] = (date[4] > 12)? (date[4] - 12) : date[4];
this.stack.push([new Date(parseInt(date[0]), parseInt(date[1]), date[2], date[3], date[4], 0).getTime(), obj]);
this.stack.sort();
return this.stack.reverse();
}
function orderSBoards(){
var dRe = /((\w+|\d+)[\D])?(\d+)[thsndr\D]*(\d+)[,\s-\.\/at\s]*(\d+:\d+)(am|pm)?/mi;
var iCell = document.getElementsByTagName("td");
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).className == "windowbg2" && iCell.item(c).width == "24%"){
if(iCell.item(c).innerHTML.match(/(Today<\/b>|Yesterday) at (\d+:\d+)(am|pm)?/mi)){
var now = new Date();
var h = parseInt(RegExp.$2.split(":")[0]);
var mi = parseInt(RegExp.$2.split(":")[1]);
var d = (RegExp.$1.match(/Yesterday/i))? (now.getDate() - 1) : now.getDate();
if(RegExp.$3.match(/pm/i)){
h += 12;
}
new Date().toTimestamp([now.getFullYear(), (now.getMonth() + 1), d, h, mi], iCell.item(c).parentNode);
} else if(iCell.item(c).innerHTML.match(dRe)){
var d = parseInt(RegExp.$3);
var y = parseInt(RegExp.$4);
var h = parseInt(RegExp.$5.split(":")[0]);
var mi = parseInt(RegExp.$5.split(":")[1]);
var m = RegExp.$2;
if(RegExp.$6.match(/pm/i)){
h += 12;
}
new Date().toTimestamp([y, m, d, h, mi], iCell.item(c).parentNode);
} else {
new Date().toTimestamp([1000, 1, 1, 1, 1], iCell.item(c).parentNode);
}
iCell.item(c).parentNode.parentNode.id = "subboardstb";
iCell.item(c).parentNode.parentNode.removeChild(iCell.item(c).parentNode);
c --;
}
}
if(document.getElementById("subboardstb")){
var sbTB = document.getElementById("subboardstb");
for(s = 0; s < new Date().stack.length; s ++){
sbTB.appendChild(new Date().stack
}
}
}
if(location.href.match(/board=\w+/i)){
orderSBoards();
}
//-->
</script>