Conforums Support
Board Enhancements >> Hacks >> Moderator Default Messages
http://support.conforums.com/index.cgi?board=code&action=display&num=1344435409

Moderator Default Messages
Post by Dalton on Aug 8th, 2012, 09:16am

This script adds a dropdown for admins and mods allowing them to add a default message to their post, explaining if a request has been completed, or a topic locked or whatever you want it to say.

Code:
<script language="javascript" type="text/javascript">
/* Original concept by Hechizero, rewritten as a conforums code by Dalton */

var DefaultMessages=[];
DefaultMessages[0]=[];

DefaultMessages[1]=['Thread Against TOS','This thread is against Conforums TOS.\nLocked','yes'];
DefaultMessages[2]=['Request Done','This request has been finished.\nIf you do not like the product please pm the creator.','yes'];
DefaultMessages[3]=['Off Topic','This thread is off topic.\nLocked','yes'];
DefaultMessages[4]=['Edit Me','Edit me.\nLocked','yes/no']
if (document.postmodify && document.postmodify.lock) {
var the_table=document.postmodify.lock.parentNode.parentNode.parentNode;
var newR=the_table.insertRow(the_table.rows.length);
newR.insertCell(0).innerHTML='<font size="2"><b>Default Message:</b></font>';
newR.cells[0].className='windowbg';
var newInput=document.createElement('input');
newInput.type='checkbox';
newInput.id='defaultMessageCheck';
newInput.onclick=function () {
var selectedNum=document.getElementById('defaultMessage').selectedIndex;
if (this.checked && selectedNum>0) {
document.postmodify.message.value+=DefaultMessages[selectedNum][1];
DefaultMessages[0][DefaultMessages[0].length]=DefaultMessages[selectedNum][1];
if (!document.postmodify.lock.checked && DefaultMessages[selectedNum][2].match(/^yes$/i)) {
document.postmodify.lock.checked=true;
}
} else {
for (var h=0;h<DefaultMessages[0].length;h++) {
document.postmodify.message.value=document.postmodify.message.value.replace(DefaultMessages[0][h],'');
}
DefaultMessages[0].length=0;
if (document.postmodify.lock.checked) {
document.postmodify.lock.checked=false;
}
}
};
var newSelect=document.createElement('select');
newSelect.id='defaultMessage';
newSelect.options[0]=new Option('---------','',false,false);
for (var h=1;h<DefaultMessages.length;h++) {
newSelect.options[h]=new Option(DefaultMessages[h][0],'',false,false);
}
newSelect.onchange=function () {
if (document.getElementById('defaultMessageCheck').checked && this.selectedIndex>0) {
document.postmodify.message.value+=DefaultMessages[this.selectedIndex][1];
DefaultMessages[0][DefaultMessages[0].length]=DefaultMessages[this.selectedIndex][1];
if (!document.postmodify.lock.checked && DefaultMessages[this.selectedIndex][2].match(/^yes$/i)) {
document.postmodify.lock.checked=true;
}
}
};
newC=newR.insertCell(1); newC.appendChild(newInput); newC.appendChild(document.createTextNode(' ')); newC.appendChild(newSelect);
}
</script>