made it look like an email reply
I wanted the quote to look like an embedded email reply... and the last IE 5.5 JS kept throwing errors for me when I had the regExp inside the function.
Result is when you click 'quote in reply' link you get something that looks like this in the textarea...
On Thu, Jul 30 2009 12, 'Kurt M' wrote:
>Is this thing on?
>Well, I really need help with my problem. I think it starts like this and then
>goes like this.
>Thanks,
>Kurt
Here is my JS for scp.js
var regExp = /<\/?+>/gi;
function ReplaceTags(xStr){
xStr = xStr.replace(/<BR.*\/>/gi,"\n");
xStr = xStr.replace(regExp,"");
xStr = xStr.replace(/>/gi,">");
xStr = xStr.replace(/</gi,"<");
xStr = xStr.replace(/ /gi," ");
xStr = xStr.replace(/\n/gi,"\n>");
return ">"+xStr;
}
function quoteMsg(msgID,fieldName,userName,time)
{
//Akon - what's an akon? Eddie rocks.
if (! msgID) {return false}
if (! fieldName){return false}
if (document.getElementById){
var fixedContent = ReplaceTags(document.getElementById(msgID).innerHTML);
fieldName.value+="On "+time+", '"+userName+"' wrote: \n"+fixedContent;
} else if (document.all){
var fixedContent = ReplaceTags(document.all.innerHTML);
fieldName.value+="On "+time+", '"+userName+"' wrote: \n"+fixedContent;
}
fieldName.value+="> n";
return false;
}
and here is the corresponding viewticket.inc.php
<table align="center" class="message" cellspacing="0" cellpadding="1" width="100%">
<tr><th><?=Format:($msg_row)?></th><th style="text-align"><a href="#reply" onClick="quoteMsg('<?=$msg_row?>',document.reply.response,'<?echo $ticket->getName();?>','<?=Format:($msg_row)?>');">Quote In Your Reply</a></th></tr>
<?if($msg_row>0){ ?>
<tr class="header"><td colspan="2"><?=$ticket->getAttachmentStr($msg_row,'M')?></td></tr>
<?}?>
<tr><td colspan="2" id="<?=$msg_row?>"><?=Format:($msg_row)?> </td></tr>
</table>