Post by Todge on Aug 4, 2006 12:11:31 GMT -8
This will enable members to lock or unlock their own threads..
It will add a button beside the quote/modify/delete buttons of the first post to either lock or unlock the thread..
Put it at or near the top of your Global Footer or the footer of the board you want it to effect if not your entire forum..
Edit the code where it says (at the top).
It will add a button beside the quote/modify/delete buttons of the first post to either lock or unlock the thread..
Put it at or near the top of your Global Footer or the footer of the board you want it to effect if not your entire forum..
<script type="text/javascript">
<!--
/*
Enable original poster to (un)lock threads
by Todge
Copyright © 2006
Please keep this header intact
*/
// Edit below....
var lockButton = 'URL OF LOCK BUTTON';
var unlockButton = 'URL OF UNLOCK BUTTON';
// Edit above....
// If locked remove reply and quote buttons...
if(location.href.match('action=display') && pb_username != 'admin')
{
var locked = 'no';
var poster = 'Guest';
var lock = new Array();
for(p=0; p<document.links.length; p++)
{
if(document.links[p].href.match('viewprofile&user=') && poster == 'Guest')
{
poster = document.links[p].href.split('viewprofile&user=')[1];
}
if(document.links[p].href.match('quote='))
{
lock[0] = document.links[p].href+'lock';
lock[1] = document.links[p];
break;
}}
var td = document.getElementsByTagName('td');
for(t=0; t<td.length; t++)
{
if(td[t].vAlign == 'top' && td[t].width == '100%')
{
if(td[t].innerHTML.split(/<table/i)[0].match('(LOCKED)'))
{
locked = 'yes';
}}}
if(locked == 'yes')
{
for(l=0; l<document.links.length; l++)
{
if(document.links[l].href.match(/action=(post|modify|delete)/))
{
document.links[l].style.display = 'none';
}}
var quickR = document.getElementsByTagName('font');
for(l=0; l<quickR.length; l++)
{
if(quickR[l].innerHTML.match('Quick Reply') && quickR[l].parentNode.className == 'titlebg')
{
quickR = quickR[l].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
quickR.style.display = 'none';
quickR.previousSibling.style.display = 'none';
quickR.previousSibling.previousSibling.style.display = 'none';
break;
}}
// Add button to (un)lock thread...
if(pb_username != 'Guest' && pb_username == poster && lock[0].match('&page=1lock'))
{
lock[1].parentNode.innerHTML = '<a href="'+lock[1].nextSibling.nextSibling.href+'&locked=yes'+'"><img src="'+unlockButton+'" alt="Unlock thread" border="0"></a>'+lock[1].parentNode.innerHTML;
}}
else
{
if(pb_username != 'Guest' && pb_username == poster && lock[0].match('&page=1lock'))
{
lock[1].parentNode.innerHTML = '<a href="'+lock[1].nextSibling.nextSibling.href+'&locked=no'+'"><img src="'+lockButton+'" alt="Lock thread" border="0"></a>'+lock[1].parentNode.innerHTML;
}}}
// Lock or unlock thread...
if(location.href.match('action=modifypost') && location.href.match(/&locked=(yes|no)/) && pb_username != 'admin')
{
var formTable;
var tbl = document.getElementsByTagName('a');
for(t=0; t<tbl.length; t++)
{
if(tbl[t].className=='nav')
{
tbl[t].style.display='none';
tbl[t].parentNode.removeChild(tbl[t].nextSibling);
formTable = tbl[t].parentNode.parentNode.parentNode.parentNode;
}}
var verifyLock = formTable.getElementsByTagName('TD');
for(t=0; t<verifyLock.length; t++)
{
if(!verifyLock[t].innerHTML.match('value="Modify Post"'))
{
verifyLock[t].parentNode.style.display='none';
}
else
{
if(verifyLock[t].firstChild.nodeName=='FONT')
{
verifyLock[t].firstChild.size=5;
var button = verifyLock[t].getElementsByTagName('input')
for(i=0; i<button.length; i++)
{
if(button[i].value=='Modify Post')
{
if(document.postForm.subject.value.match('(LOCKED)'))
{
button[i].value='Unlock';
}
else
{
button[i].value='Lock';
}}
else if(button[i].value=='Reset')
{
button[i].value='Cancel';
button[i].onmousedown = function(){location.href=document.referrer;}
}
else
{
button[i].style.display='none';
}}
if(document.postForm.subject.value.match('(LOCKED)'))
{
verifyLock[t].firstChild.innerHTML='Are you sure you want to unlock this thread?';
document.postForm.subject.value = document.postForm.subject.value.split('(LOCKED) ')[1];
}
else
{
verifyLock[t].firstChild.innerHTML='Are you sure you want to lock this thread?';
document.postForm.subject.value = '(LOCKED) '+document.postForm.subject.value;
}}}}}
// -->
</script>
Edit the code where it says (at the top).