Post by Scorpian on Oct 6, 2006 20:34:13 GMT -8
<script type='text/javascript'>
/* Dual-Image Sticky Splitter by Scorpian
http://roddyinnovations.com */
/*=== Edit These ===*/
var headImg = ['yes','URL_OF_HEAD_IMAGE']; // [Turn on head image? 'yes or 'no', url of the head image]
var baseImg = ['yes','URL_OF_BASE_IMAGE']; // [Turn on base image? 'yes or 'no', url of the base image]
var gHeight = '20'; // Distance between tables
var cNames = ['Important Topics','Normal Topics']; // Names of the tables
/*=== No Touchy! ===*/
var riTable = document.getElementsByTagName('table');
var hImg = document.createElement('img'); var bImg = document.createElement('img');
hImg.src = headImg[1]; bImg.src = baseImg[1]; var gDiv = document.createElement('div');
gDiv.style.height = gHeight + 'px'; var theMainTable = document.createElement('table');
with(theMainTable){
cellSpacing = 1; cellPadding = 4; border = 0; align = 'center'
width = '100%'; className = 'bordercolor';
appendChild(document.createElement('tbody'));
}
if(location.href.match(/board=/i) && !location.href.match(/action=/i)){
for(a=0; a<riTable.length; a++){
if(riTable[a].rows[0].cells[0].className == 'titlebg' && riTable[a].rows[1] && riTable[a].rows[1].cells[0].className == 'catbg'){
if(riTable[a].rows[0].cells[0].colSpan == 8){ break; }
var stickies = false; var anyTopics = false;
riTable[a-1].style.backgroundColor = 'transparent';
var newCellA = riTable[a-1].insertRow(-1).insertCell(0);
var newCellB = riTable[a-1].insertRow(-1).insertCell(0);
if(headImg[0] == 'yes'){ newCellA.appendChild(hImg.cloneNode(true)); }
newCellA.appendChild(theMainTable.cloneNode(true));
if(baseImg[0] == 'yes'){ newCellA.appendChild(bImg.cloneNode(true)); }
newCellA.appendChild(gDiv.cloneNode(true));
if(headImg[0] == 'yes'){ newCellB.appendChild(hImg.cloneNode(true)); }
newCellB.appendChild(theMainTable.cloneNode(true));
if(baseImg[0] == 'yes'){ newCellB.appendChild(bImg.cloneNode(true)); }
var tbodA = newCellA.getElementsByTagName('table')[0].firstChild;
var tbodB = newCellB.getElementsByTagName('table')[0].firstChild;
tbodA.appendChild(riTable[a].rows[1].cloneNode(true));
tbodB.appendChild(riTable[a].rows[1].cloneNode(true));
tbodA.parentNode.rows[0].cells[2].firstChild.firstChild.innerHTML = cNames[0];
tbodB.parentNode.rows[0].cells[2].firstChild.firstChild.innerHTML = cNames[1];
for(b=0; b<riTable[a].rows.length; b++){
if(riTable[a].rows[b].cells[0] && riTable[a].rows[b].cells[0].className == 'windowbg2' && riTable[a].rows[b].cells[1] && riTable[a].rows[b].cells[1].className == 'windowbg2'){
if(riTable[a].rows[b].cells[0].innerHTML.match(/sticky/i) && riTable[a].rows[b].cells[2] && !riTable[a].rows[b].cells[2].innerHTML.match(/Announcement:/i)){
var word = '<font size="2">Sticky:</font> '; var isStick = true; var stickies = true;
}else if(riTable[a].rows[b].cells[2].innerHTML.match(/Announcement:/i)){
var word = ''; var isStick = true; var stickies = true;
}else{
var word = ''; var isStick = false; var anyTopics = true;
}
riTable[a].rows[b].cells[2].innerHTML = word + riTable[a].rows[b].cells[2].innerHTML;
if(isStick){
tbodA.appendChild(riTable[a].rows[b].cloneNode(true));
}else{
tbodB.appendChild(riTable[a].rows[b].cloneNode(true));
}
riTable[a].rows[b].style.display = 'none';
}
}
tbodA.appendChild(riTable[a].rows[0].cloneNode(true));
tbodB.appendChild(riTable[a].rows[0].cloneNode(true));
riTable[a-1].rows[0].style.display = 'none';
if(stickies || anyTopics){
newCellA.style.display = (stickies) ? '' : 'none';
newCellB.style.display = (anyTopics) ? '' : 'none';
}else{
newCellA.style.display = 'none';
var nCell = tbodB.parentNode.insertRow(1).insertCell(0);
nCell.className = 'windowbg'; nCell.align = 'center';
nCell.colSpan = 7; nCell.style.fontStyle = 'italic';
nCell.style.fontSize = '12px';
nCell.appendChild(document.createTextNode('There are no topics in this board.'));
}
break;
}
}
}
</script>
Created By: Scorpian
Tested In: Mozilla Firefox 1.5 & Internet Explorer 6
Goes In: Global or Board Footers
Code Preview: Click Here
Alright, this code is relativaley simple. It creates two tables. One is for stickied and announcement threads. The other is for normal threads. Head/Base Images are optional. If there are no stickied threads, the table for them will not be visible. The same goes for normal threads. A message will appear if there are no posts saying just that. Oh, and the code will not load if Advanced Moderation is on.
Editing should be simple. For the head/base variables, I used an array. The first variable is 'yes' or 'no'. This is whether or not you want said image to be seen. The second is the url of the image. It's only required if the first one was 'yes'.
gHeight should be easy enough. It's the height (in pixels) of the gap between the two tables. cNames is also simple. The first word is the title of the table for stickied threads. The second word is the title for the table of normal threads. Easy, right?
If you have any questions, just ask. Enjoy the code. Blah blah, yadda yadda...