Post by Code Dragon on Feb 25, 2007 20:31:34 GMT -8
Code name: Topic Descriptions
Description: This code will allow you to have descriptions in topics. It adds a Topic Description field in the post form, and it adds a Description: below the subject when you're browsing through threads. It replaces everywhere it needs to, and if you wanna see what it looks like, then please check the preview.
Placement: Global Footer
Preview: Here
<script type="text/javascript">
<!--
/*
*********************
Topic Descriptions
By Code Dragon
Global Footer
This header must remain intact at all times
This code may not be duplicated or claimed as yours
Code from chaobreederxl2.proboards80.com/
*********************
*/
var js_self = document; var getID = js_self.getElementById;
function $(theid){
return getID(theid);
}
var TopicDescriptions = {
topicDescReplace:function(){
var td = js_self.getElementsByTagName('td');
for(x=0;x<td.length;x++){
if((td[x].width.match(/4(3|8)%/) && td[x].className == "windowbg") && (td[x].innerHTML.match(/">(.+?)\|(.+?)<\/a>/i))){
td[x].innerHTML = td[x].innerHTML.replace(/">(.+?)\|(.+?)<\/a>/i, '">$1</a><br/><font size="1">Description: <span style="font-weight:normal;">$2</span></font>');
}
}
},
addRowAndCells:function(){
var tab = js_self.getElementsByTagName('table');
for(le=4;le<tab.length;le++){
if(tab[le-1].className == "bordercolor" && tab[le].firstChild.firstChild.firstChild.innerHTML.match(/(Modify Post|Post Message)/)){
var insRow = tab[le].insertRow(2);
var insCell = insRow.insertCell(0);
insCell.className = "windowbg";
insCell.width = "30%";
var topicDescFont = js_self.createElement("font");
topicDescFont.setAttribute("size","2");
topicDescFont.innerHTML = "Topic Description: ";
insCell.appendChild(topicDescFont);
var insInputCell = insRow.insertCell(1);
insInputCell.className = "windowbg";
insInputCell.width = "70%";
var topicDescInput = js_self.createElement("input");
var topicSubject = js_self.postForm.subject;
var TDV = (topicSubject.value.match(/(.+?)\|(.+?)/)) ? topicSubject.value.split("|")[1] : "";
with(topicDescInput){
setAttribute("type", "text");
setAttribute("value",TDV);
setAttribute("size", "40");
setAttribute("maxlength", "50");
setAttribute("id", "topicDesc");
}
insInputCell.appendChild(topicDescInput);
}
}
},
replaceOtherDescTags:function(){
var t = js_self.getElementsByTagName('td');
if(location.href.match(/(#|((\.cgi|\?|\/|home)$))/)){
for(d=0;d<t.length;d++){
if(t[d].innerHTML.match(/">(.+?)\|(.+?)?<\/a>/gi)){
t[d].innerHTML = t[d].innerHTML.replace(/">(.+?)\|(.+?)?<\/a>/gi, "\">$1</a>");
}
}
}else{
for( d = 0; d < t.length; d++){
if(t[d].innerHTML.match(/">(.+?)\|(.+?)?<\/a>/gi)){
t[d].innerHTML = t[d].innerHTML.replace(/">(.+?)\|(.+?)?<\/a>/gi, "\">$1</a>");
}
}
if(t[d].innerHTML.match(/">(.+?)\|(.+?)?<\/font>/gi)){
t[d].innerHTML = t[d].innerHTML.replace(/<font size="2"><b>(.+?)\|(.+?)?<\/b><\/font>/gi, "<font size=\"2\"><b>$1</b></font><br/><font size=\"1\">$2</font>");
}
}
},
saveDesc:function(){
var topicSubj = js_self.postForm.subject;
var descText = document.getElementById('topicDesc').value;
if (descText != '') {
(!js_self.postForm.subject.value.match(/(.+?)\|(.+?)/)) ? js_self.postForm.subject.value+="|"+document.getElementById('topicDesc').value : js_self.postForm.subject.value = js_self.postForm.subject.value.replace(js_self.postForm.subject.value.split("|")[1], document.getElementById('topicDesc').value);
((js_self.postForm.subject.value.length+1+document.getElementById('topicDesc').value.length)>50) ? js_self.postForm.subject.value = js_self.postForm.subject.value.substr(0,50) : "";
}}
}
if(this.location.href.match(/board=(.+?)$/i)){
TopicDescriptions.topicDescReplace();
}
if(!this.location.href.match(/(headersfooters(2|3)?)|(board=)/i) && !js_self.postForm){
TopicDescriptions.replaceOtherDescTags();
}
if((!this.location.href.match(/index\.cgi$/)&&js_self.postForm) || location.href.match(/preview/)){
TopicDescriptions.addRowAndCells();
}
if(this.location.href.match(/display&/)){
js_self.title = js_self.title.split(" - ")[0]+" - "+js_self.title.split(" - ")[1].replace(/(.+?)\|(.+?)/, "$1 - $2");
var t = js_self.getElementsByTagName('td');
for( d = 0; d < t.length; d++){
if(t[d].width == "55%" && t[d].innerHTML.match(/<font size="2"><b>(.+?)\|(.+?)<\/b><\/font>/)){
t[d].innerHTML = t[d].innerHTML.replace(/<font size="2"><b>(.+?)\|(.+?)<\/b><\/font>/, "<font size=\"2\"><b>$1</b></font><br/><font size=\"1\">$2</font>");
}
if(t[d].className == "catbg" && t[d].innerHTML.match(/Topic: (.+?)\|(.+?) \(Read (\d+?) time(s)?\)/i)){
t[d].innerHTML = t[d].innerHTML.replace(/Topic: (.+?)\|(.+?) \(Read (\d+?) time(s)?\)/i, "$1 (Read $3 time$4)<br/>$2");
}
}
}
if(js_self.postForm){
js_self.postForm.subject.value = js_self.postForm.subject.value.split("|")[0];
if(js_self.addEventListener){
js_self.postForm.addEventListener('submit', function(){
TopicDescriptions.saveDesc();
}, false);
}else{
js_self.postForm.attachEvent('onsubmit', function(){
TopicDescriptions.saveDesc();
})
}
}
// -->
</script>
Sept 2010: Fixed an error with the for() loop that was causing it to lag pages.
July 22nd, 2007: Fixed an error with saveDesc() and removed the try/catch constructors.
May 26th, 2007: Fixed a ReferenceError
Description: This code will allow you to have descriptions in topics. It adds a Topic Description field in the post form, and it adds a Description: below the subject when you're browsing through threads. It replaces everywhere it needs to, and if you wanna see what it looks like, then please check the preview.
Placement: Global Footer
Preview: Here
<script type="text/javascript">
<!--
/*
*********************
Topic Descriptions
By Code Dragon
Global Footer
This header must remain intact at all times
This code may not be duplicated or claimed as yours
Code from chaobreederxl2.proboards80.com/
*********************
*/
var js_self = document; var getID = js_self.getElementById;
function $(theid){
return getID(theid);
}
var TopicDescriptions = {
topicDescReplace:function(){
var td = js_self.getElementsByTagName('td');
for(x=0;x<td.length;x++){
if((td[x].width.match(/4(3|8)%/) && td[x].className == "windowbg") && (td[x].innerHTML.match(/">(.+?)\|(.+?)<\/a>/i))){
td[x].innerHTML = td[x].innerHTML.replace(/">(.+?)\|(.+?)<\/a>/i, '">$1</a><br/><font size="1">Description: <span style="font-weight:normal;">$2</span></font>');
}
}
},
addRowAndCells:function(){
var tab = js_self.getElementsByTagName('table');
for(le=4;le<tab.length;le++){
if(tab[le-1].className == "bordercolor" && tab[le].firstChild.firstChild.firstChild.innerHTML.match(/(Modify Post|Post Message)/)){
var insRow = tab[le].insertRow(2);
var insCell = insRow.insertCell(0);
insCell.className = "windowbg";
insCell.width = "30%";
var topicDescFont = js_self.createElement("font");
topicDescFont.setAttribute("size","2");
topicDescFont.innerHTML = "Topic Description: ";
insCell.appendChild(topicDescFont);
var insInputCell = insRow.insertCell(1);
insInputCell.className = "windowbg";
insInputCell.width = "70%";
var topicDescInput = js_self.createElement("input");
var topicSubject = js_self.postForm.subject;
var TDV = (topicSubject.value.match(/(.+?)\|(.+?)/)) ? topicSubject.value.split("|")[1] : "";
with(topicDescInput){
setAttribute("type", "text");
setAttribute("value",TDV);
setAttribute("size", "40");
setAttribute("maxlength", "50");
setAttribute("id", "topicDesc");
}
insInputCell.appendChild(topicDescInput);
}
}
},
replaceOtherDescTags:function(){
var t = js_self.getElementsByTagName('td');
if(location.href.match(/(#|((\.cgi|\?|\/|home)$))/)){
for(d=0;d<t.length;d++){
if(t[d].innerHTML.match(/">(.+?)\|(.+?)?<\/a>/gi)){
t[d].innerHTML = t[d].innerHTML.replace(/">(.+?)\|(.+?)?<\/a>/gi, "\">$1</a>");
}
}
}else{
for( d = 0; d < t.length; d++){
if(t[d].innerHTML.match(/">(.+?)\|(.+?)?<\/a>/gi)){
t[d].innerHTML = t[d].innerHTML.replace(/">(.+?)\|(.+?)?<\/a>/gi, "\">$1</a>");
}
}
if(t[d].innerHTML.match(/">(.+?)\|(.+?)?<\/font>/gi)){
t[d].innerHTML = t[d].innerHTML.replace(/<font size="2"><b>(.+?)\|(.+?)?<\/b><\/font>/gi, "<font size=\"2\"><b>$1</b></font><br/><font size=\"1\">$2</font>");
}
}
},
saveDesc:function(){
var topicSubj = js_self.postForm.subject;
var descText = document.getElementById('topicDesc').value;
if (descText != '') {
(!js_self.postForm.subject.value.match(/(.+?)\|(.+?)/)) ? js_self.postForm.subject.value+="|"+document.getElementById('topicDesc').value : js_self.postForm.subject.value = js_self.postForm.subject.value.replace(js_self.postForm.subject.value.split("|")[1], document.getElementById('topicDesc').value);
((js_self.postForm.subject.value.length+1+document.getElementById('topicDesc').value.length)>50) ? js_self.postForm.subject.value = js_self.postForm.subject.value.substr(0,50) : "";
}}
}
if(this.location.href.match(/board=(.+?)$/i)){
TopicDescriptions.topicDescReplace();
}
if(!this.location.href.match(/(headersfooters(2|3)?)|(board=)/i) && !js_self.postForm){
TopicDescriptions.replaceOtherDescTags();
}
if((!this.location.href.match(/index\.cgi$/)&&js_self.postForm) || location.href.match(/preview/)){
TopicDescriptions.addRowAndCells();
}
if(this.location.href.match(/display&/)){
js_self.title = js_self.title.split(" - ")[0]+" - "+js_self.title.split(" - ")[1].replace(/(.+?)\|(.+?)/, "$1 - $2");
var t = js_self.getElementsByTagName('td');
for( d = 0; d < t.length; d++){
if(t[d].width == "55%" && t[d].innerHTML.match(/<font size="2"><b>(.+?)\|(.+?)<\/b><\/font>/)){
t[d].innerHTML = t[d].innerHTML.replace(/<font size="2"><b>(.+?)\|(.+?)<\/b><\/font>/, "<font size=\"2\"><b>$1</b></font><br/><font size=\"1\">$2</font>");
}
if(t[d].className == "catbg" && t[d].innerHTML.match(/Topic: (.+?)\|(.+?) \(Read (\d+?) time(s)?\)/i)){
t[d].innerHTML = t[d].innerHTML.replace(/Topic: (.+?)\|(.+?) \(Read (\d+?) time(s)?\)/i, "$1 (Read $3 time$4)<br/>$2");
}
}
}
if(js_self.postForm){
js_self.postForm.subject.value = js_self.postForm.subject.value.split("|")[0];
if(js_self.addEventListener){
js_self.postForm.addEventListener('submit', function(){
TopicDescriptions.saveDesc();
}, false);
}else{
js_self.postForm.attachEvent('onsubmit', function(){
TopicDescriptions.saveDesc();
})
}
}
// -->
</script>
Sept 2010: Fixed an error with the for() loop that was causing it to lag pages.
July 22nd, 2007: Fixed an error with saveDesc() and removed the try/catch constructors.
May 26th, 2007: Fixed a ReferenceError