Post by MSC™ on Jun 3, 2007 15:02:53 GMT -8
QUICK DESCRIPTION: Removes the "Delete" button from the first post in a thread (assuming that there are replies), and replaces it with the "Remove Topic" button for staff members with the correct powers.
DETAILED EXPLANATION: Sometimes, users erroneously think that deleting the first post in their thread will remove the thread. Of course, this is not true, and it can lead to awkward situations. This code will help prevent such things from happening by removing the "Delete" button from the first post in a thread. If there are no replies to the thread, then the code won't do anything, as deleting the only post in a thread WILL cause the thread to be removed. If a staff member who has the power to remove threads views the post, then the delete button will be replaced with the "Remove Topic" button.
COMPATIBILITY: Needs to come BEFORE any mini-profile or post layout hacks.
LOCATION: Goes in either Global or Board Footers. Global will cause the code to affect the whole forum, while Board will cause the code to only affect the board in question.
<script type="text/javascript">
<!--
// Prevent Deletion of Initial Thread Posts, by MegaShadowChao. May not be duplicated, altered, or reposted except be the author. //
var deleteRemoveButton=1; // Edit THIS LINE ONLY!!
// No editing below here... //
var td=document.getElementsByTagName('td');
var deleteTd=0;
var adminTd=0;
var deleteLink=0;
var removeLink=0;
var numPosts=0;
for(count=0; count<td.length; count++){
with(td[count]){
if(width=="20%"&&className.match("windowbg")&&(innerHTML.match(/Posts: (.+?)</)||innerHTML.match(/Guest/))){
if(td[count+1].getElementsByTagName('td').length>1){
count+=4;
numPosts++;
if(numPosts==1){
var tdA=td[count].getElementsByTagName('a');
for(count2=0; count2<tdA.length; count2++){
if(tdA[count2].href.match(/action=deletepost/)&&!tdA[count2].href.match(/page=[234567890]/)){ deleteTd=count; deleteLink=count2; }
}
}
}
} else if(width=="100%"&&getElementsByTagName('img').length>0){
if(getElementsByTagName('img')[0].alt=="Admin Functions: "){
for(count2=0; count2<getElementsByTagName('a').length; count2++){
if(getElementsByTagName('a')[count2].href.match(/action=removethread/)){ adminTd=count; removeLink=count2; }
}
break;
}
}
}
}
if(numPosts>1&&deleteTd>0){
td[deleteTd].getElementsByTagName('a')[deleteLink].style.display="none";
if(adminTd>deleteTd){
if(deleteRemoveButton){
td[deleteTd].appendChild(td[adminTd].getElementsByTagName('a')[removeLink]);
} else {
td[deleteTd].innerHTML+='<a href="'+td[adminTd].getElementsByTagName('a')[removeLink].href+'">'+td[adminTd].getElementsByTagName('a')[removeLink].innerHTML+'</a>'
}
}
}
//-->
</script>
You can edit the number in RED; it controls what is done with the "Remove Topic" button for staff members with the correct powers. If the number is set to zero, then the button will stay in the Admin Functions panel as well as being added to the first post. If it is set to one (default), then the button will be removed from the Admin Functions panel and only appear in the first post. Feel free to PM me if you have any questions regarding the code.
EDIT [6/18/07]: Code no longer interferes with posts that aren't on the first page of a thread. Also, some general optimizations have been added.
DETAILED EXPLANATION: Sometimes, users erroneously think that deleting the first post in their thread will remove the thread. Of course, this is not true, and it can lead to awkward situations. This code will help prevent such things from happening by removing the "Delete" button from the first post in a thread. If there are no replies to the thread, then the code won't do anything, as deleting the only post in a thread WILL cause the thread to be removed. If a staff member who has the power to remove threads views the post, then the delete button will be replaced with the "Remove Topic" button.
COMPATIBILITY: Needs to come BEFORE any mini-profile or post layout hacks.
LOCATION: Goes in either Global or Board Footers. Global will cause the code to affect the whole forum, while Board will cause the code to only affect the board in question.
<script type="text/javascript">
<!--
// Prevent Deletion of Initial Thread Posts, by MegaShadowChao. May not be duplicated, altered, or reposted except be the author. //
var deleteRemoveButton=1; // Edit THIS LINE ONLY!!
// No editing below here... //
var td=document.getElementsByTagName('td');
var deleteTd=0;
var adminTd=0;
var deleteLink=0;
var removeLink=0;
var numPosts=0;
for(count=0; count<td.length; count++){
with(td[count]){
if(width=="20%"&&className.match("windowbg")&&(innerHTML.match(/Posts: (.+?)</)||innerHTML.match(/Guest/))){
if(td[count+1].getElementsByTagName('td').length>1){
count+=4;
numPosts++;
if(numPosts==1){
var tdA=td[count].getElementsByTagName('a');
for(count2=0; count2<tdA.length; count2++){
if(tdA[count2].href.match(/action=deletepost/)&&!tdA[count2].href.match(/page=[234567890]/)){ deleteTd=count; deleteLink=count2; }
}
}
}
} else if(width=="100%"&&getElementsByTagName('img').length>0){
if(getElementsByTagName('img')[0].alt=="Admin Functions: "){
for(count2=0; count2<getElementsByTagName('a').length; count2++){
if(getElementsByTagName('a')[count2].href.match(/action=removethread/)){ adminTd=count; removeLink=count2; }
}
break;
}
}
}
}
if(numPosts>1&&deleteTd>0){
td[deleteTd].getElementsByTagName('a')[deleteLink].style.display="none";
if(adminTd>deleteTd){
if(deleteRemoveButton){
td[deleteTd].appendChild(td[adminTd].getElementsByTagName('a')[removeLink]);
} else {
td[deleteTd].innerHTML+='<a href="'+td[adminTd].getElementsByTagName('a')[removeLink].href+'">'+td[adminTd].getElementsByTagName('a')[removeLink].innerHTML+'</a>'
}
}
}
//-->
</script>
You can edit the number in RED; it controls what is done with the "Remove Topic" button for staff members with the correct powers. If the number is set to zero, then the button will stay in the Admin Functions panel as well as being added to the first post. If it is set to one (default), then the button will be removed from the Admin Functions panel and only appear in the first post. Feel free to PM me if you have any questions regarding the code.
EDIT [6/18/07]: Code no longer interferes with posts that aren't on the first page of a thread. Also, some general optimizations have been added.