Post by mrsmiley on Jan 23, 2008 16:53:58 GMT
Well, I'm sure in all our noob days we've written enormous codes completing tasks which could have been optimized to a fifth as big. Here's a thread to post some of yours!
This is one I made a while back, when I first visited Proboards. It was a simple category splitter, yet horrible coded. Fun to read up on now, hehe!
<script type='text/javascript'>
<!--
/*============================
------------------------------
Category Splitter w/ Optional Head/base Images
------------------------------
=============================*/
var head = ["yes" , "" , "50px"];
var base = ["no" , "" , "50px"];
var gap = "50px";
var gCell = document.getElementsByTagName('table');
var Ltable = "";
var data;
var gHead = '<tr rowSpan="3"><td colSpan="5" width="100%"><img src="' + head[1] + '" height="' + head[2] + '" width="100%"/></td></tr>';
var gBottom = '<tr rowSpan="3"><td colSpan="5" width="100%"><img src="' + base[1] + '" height="' + base[2] + '" width="100%"/></td></tr>';
var gDiv = '<div style="height: ' + gap + ';"></div>';
if(window.location.href.match(/\.com(\/(index\.cgi(#\w+|\?(action=home)?)?)?)?$/)){
for(x = 0; x < gCell.length; x++){
if(gCell[x].cellPadding == "4" && gCell[x].cellSpacing == "1" && gCell[x].innerHTML.indexOf("Info Center") == -1){
tTal = gCell[x];
tTal.parentNode.parentNode.parentNode.backgroundColor = "transparent";
forumBar = gCell[x].firstChild.firstChild.cloneNode(true);
for(r = 0; r < gCell[x].cells.length; r++){
if(gCell[x].cells[r].colSpan == "5" && gCell[x].cells[r].height == "18" && gCell[x].cells[r].innerHTML.indexOf("markallboardsread") != -1){
var markBoard = gCell[x].cells[r].firstChild.innerHTML;
}
}
for(t = 0; t < gCell[x].cells.length; t++){
if(gCell[x].cells[t].colSpan == "5" && gCell[x].cells[t].height == "18" && gCell[x].cells[t].innerHTML.indexOf("markallboardsread") == -1){
var telkj = gCell[x].innerHTML.split(gCell[x].cells[t].parentNode.innerHTML)[1]
var lkjl = telkj.split('<TD class=catbg')[0];
lkjl+= "<td class='windowbg' colspan='5' align='right'>" + markBoard + "</td></TR>";
Ltable+='<table cellspacing="0" cellpadding="0" class="trans" width="100%">';
if(head[0].match(/yes/i)){
Ltable+= gHead;
}
Ltable+= "<table id='splitz' border='0' width='100%' cellspacing='1' cellpadding='4' class='bordercolor'>";
Ltable+= "<tr>";
Ltable+= forumBar.innerHTML;
Ltable+= "</tr>";
Ltable+= "<tr><td colspan='5' class='catbg' height='18'>";
Ltable+= gCell[x].cells[t].innerHTML;
Ltable+= "</td></tr>";
Ltable+= lkjl;
Ltable+= "</table>";
if(base[0].match(/yes/i)){
Ltable+= gBottom;
}
Ltable+= gDiv;
Ltable+="</table>";
}
}
}
}
var dDiv = document.createElement('div');
dDiv.innerHTML = Ltable;
dDiv.backgroundColor = "transparent";
tTal.style.display = "none";
var gRow = tTal.parentNode.parentNode.parentNode.insertRow(0);
gRow.rowSpan = "3";
gRow.width = "100%";
gRow.backgroundColor = "transparent";
var gCel = gRow.insertCell(0);
gCel.colSpan = "5";
gCel.width = "100%";
gCel.backgroundColor = "transparent";
gCel.innerHTML = Ltable;
gCell[5].backGround = "transparent";
gCell[5].className = "trans";
}
//-->
</script>
This is one I made a while back, when I first visited Proboards. It was a simple category splitter, yet horrible coded. Fun to read up on now, hehe!
<script type='text/javascript'>
<!--
/*============================
------------------------------
Category Splitter w/ Optional Head/base Images
------------------------------
=============================*/
var head = ["yes" , "" , "50px"];
var base = ["no" , "" , "50px"];
var gap = "50px";
var gCell = document.getElementsByTagName('table');
var Ltable = "";
var data;
var gHead = '<tr rowSpan="3"><td colSpan="5" width="100%"><img src="' + head[1] + '" height="' + head[2] + '" width="100%"/></td></tr>';
var gBottom = '<tr rowSpan="3"><td colSpan="5" width="100%"><img src="' + base[1] + '" height="' + base[2] + '" width="100%"/></td></tr>';
var gDiv = '<div style="height: ' + gap + ';"></div>';
if(window.location.href.match(/\.com(\/(index\.cgi(#\w+|\?(action=home)?)?)?)?$/)){
for(x = 0; x < gCell.length; x++){
if(gCell[x].cellPadding == "4" && gCell[x].cellSpacing == "1" && gCell[x].innerHTML.indexOf("Info Center") == -1){
tTal = gCell[x];
tTal.parentNode.parentNode.parentNode.backgroundColor = "transparent";
forumBar = gCell[x].firstChild.firstChild.cloneNode(true);
for(r = 0; r < gCell[x].cells.length; r++){
if(gCell[x].cells[r].colSpan == "5" && gCell[x].cells[r].height == "18" && gCell[x].cells[r].innerHTML.indexOf("markallboardsread") != -1){
var markBoard = gCell[x].cells[r].firstChild.innerHTML;
}
}
for(t = 0; t < gCell[x].cells.length; t++){
if(gCell[x].cells[t].colSpan == "5" && gCell[x].cells[t].height == "18" && gCell[x].cells[t].innerHTML.indexOf("markallboardsread") == -1){
var telkj = gCell[x].innerHTML.split(gCell[x].cells[t].parentNode.innerHTML)[1]
var lkjl = telkj.split('<TD class=catbg')[0];
lkjl+= "<td class='windowbg' colspan='5' align='right'>" + markBoard + "</td></TR>";
Ltable+='<table cellspacing="0" cellpadding="0" class="trans" width="100%">';
if(head[0].match(/yes/i)){
Ltable+= gHead;
}
Ltable+= "<table id='splitz' border='0' width='100%' cellspacing='1' cellpadding='4' class='bordercolor'>";
Ltable+= "<tr>";
Ltable+= forumBar.innerHTML;
Ltable+= "</tr>";
Ltable+= "<tr><td colspan='5' class='catbg' height='18'>";
Ltable+= gCell[x].cells[t].innerHTML;
Ltable+= "</td></tr>";
Ltable+= lkjl;
Ltable+= "</table>";
if(base[0].match(/yes/i)){
Ltable+= gBottom;
}
Ltable+= gDiv;
Ltable+="</table>";
}
}
}
}
var dDiv = document.createElement('div');
dDiv.innerHTML = Ltable;
dDiv.backgroundColor = "transparent";
tTal.style.display = "none";
var gRow = tTal.parentNode.parentNode.parentNode.insertRow(0);
gRow.rowSpan = "3";
gRow.width = "100%";
gRow.backgroundColor = "transparent";
var gCel = gRow.insertCell(0);
gCel.colSpan = "5";
gCel.width = "100%";
gCel.backgroundColor = "transparent";
gCel.innerHTML = Ltable;
gCell[5].backGround = "transparent";
gCell[5].className = "trans";
}
//-->
</script>