Page 1 of 1

Add a canned response and keep the orignal text in textarea

Posted: Sat Mar 15, 2008 5:11 pm
by cm
version 0.94.1

Hope this tiny mod will help some one, also it would be nice if a javascript guru could sort the formatting out...

I use the canned response to add a just line or two of text to a reply, the trouble was - i could only insert one canned response, selecting another would delete the first...

This little mod will allow you to add many different canned response's and it will not overight your original wording in the reply textarea.

The only problem i find is i can not get the javascript to format "\r\n" new lines correctly, may be some one could help!

File: admin_ticket.php

line 335...
change
document.getElementById('HeskMsg').innerHTML='<textarea name="message" rows="12" cols="60">'+myMsg+'</textarea>';

to
document.getElementById('HeskMsg').innerHTML+=myMsg+'\r\n';

and change
line 354
<div id="HeskMsg" align="center"><textarea name="message" rows="12" cols="60"></textarea></div></p>
to
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>

Posted: Sat Mar 15, 2008 6:12 pm
by Klemen
Does this make a diference?

document.getElementById('HeskMsg').innerHTML+=myMsg;
document.getElementById('HeskMsg').innerHTML+='\r\n';

Haven't tested it though.

Posted: Sat Mar 15, 2008 6:42 pm
by cm
Hi, I have just tested it and still it will not format new lines correctly in a canned response..

Posted: Sun Mar 16, 2008 9:15 am
by cm
I have solved the formatting issue.

"Using innerHTML on a textarea isn't the best way of writing to it. The contents of a textarea *isn't* HTML, it is plain text (so inner*HTML* isn't appropriate), you use the value property."

This is tested and works fine...

File: admin_ticket.php

line 335...
change
document.getElementById('HeskMsg').innerHTML='<textarea name="message" rows="12" cols="60">'+myMsg+'</textarea>';

to
document.getElementById('HeskMsg').value+=myMsg+'\r\n';

and change
line 354
<div id="HeskMsg" align="center"><textarea name="message" rows="12" cols="60"></textarea></div></p>
to
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>

Posted: Sun Mar 16, 2008 10:44 am
by Klemen
Ah, that makes sense :D

Posted: Tue Feb 10, 2009 12:52 pm
by SEEKNDESTROY427
How come this didn't make it into version 2.0? It's such a simple edit... only takes a minute or less.

The following edits work with version 2.0

Code: Select all

Backup the following file: HeskDirectory/admin/admin_ticket.php

Open HeskDirectory/admin/admin_ticket.php

Find on line 663:
document.getElementById('HeskMsg').innerHTML='<textarea name="message" rows="12" cols="60">'+myMsg+'</textarea>';

Replace With:
document.getElementById('HeskMsg').value+=myMsg+'\r\n';

-----------------------------------------------------

Find on line 682:
<span id="HeskMsg"><textarea name="message" rows="12" cols="60"></textarea></span></p>

Replace With:
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>

-----------------------------------------------------
Save and upload admin_ticket.php

Credit goes to cm

Posted: Tue Feb 10, 2009 6:18 pm
by Klemen
Because only a very small fraction of users require this

Posted: Tue Feb 10, 2009 8:54 pm
by SEEKNDESTROY427
Would it be too much trouble to add it to the next update? I'm a hesk license owner and would really appreciate it. I can PM you a copy of my receipt if you like. I will even make a donation for your trouble :)

Posted: Tue Feb 10, 2009 10:27 pm
by Klemen
Adding it is not a problem, the question is which way most users prefer. From my experience the current one and this is the one I use as well.

Will see if I can find a solution that fits both requirements, but can't promise anything.

Posted: Fri May 29, 2009 5:13 pm
by allawrence
Just to add my voice to the need for something like this to be included...

If I understand how this works(I will test it this weekend) is it gives the ability to not replace existing verbiage in the "add reply" box when using the canned response and to allow multiple selections of canned responses.

Do I have this right? If so, that is a definite need on our part.

Posted: Mon Aug 10, 2009 9:28 pm
by SEEKNDESTROY427
The following edits work with version 2.1

Code: Select all

Backup the following file: HeskDirectory/admin/admin_ticket.php

Open HeskDirectory/admin/admin_ticket.php

Find on line 726:
document.getElementById('HeskMsg').innerHTML='<textarea name="message" id="message" rows="12" cols="60">'+myMsg+'</textarea>';

Replace With:
document.getElementById('HeskMsg').value+=myMsg+'\r\n';

-----------------------------------------------------

Find on line 772:
<span id="HeskMsg"><textarea name="message" id="message" rows="12" cols="60"></textarea></span></p>

Replace With:
<textarea id="HeskMsg" name="message" rows="12" cols="60"></textarea></p>

-----------------------------------------------------
Save and upload admin_ticket.php

Credit goes to cm

Posted: Mon Aug 10, 2009 11:54 pm
by Klemen
No need for these edits as in 2.1 you can, when replying to a ticket, choose to either replace the message with canned response or add it to the message.

Posted: Tue Aug 11, 2009 12:48 am
by SEEKNDESTROY427
Klemen wrote:No need for these edits as in 2.1 you can, when replying to a ticket, choose to either replace the message with canned response or add it to the message.
I understand that and appreciate the option but since I always add my canned messages at the bottom I figured I'd modify it so I don't have to check "Add to the bottom" and then select my message. It's one less step I have to take to add my canned message.

I'm sure I'm not the only that is lazy and likes it as simple as possible with as few steps as possible. That's why I posted the script modification.

Maybe if there was an option under settings which one to set as the default I wouldn't have to modify your awesome software.

Posted: Tue Aug 11, 2009 8:46 am
by Klemen
OK, just making sure you saw the new feature.

You could also just move the checked="checked" from line 764 to 765 and keep both options while having the "Add to the bottom" selected by default. So

Code: Select all

	    <label><input type="radio" name="mode" id="moderep" value="0" checked="checked" /> <?php echo $hesklang['mrep']; ?></label><br />
	    <label><input type="radio" name="mode" id="modeadd" value="1" /> <?php echo $hesklang['madd']; ?></label>
should be

Code: Select all

	    <label><input type="radio" name="mode" id="moderep" value="0" /> <?php echo $hesklang['mrep']; ?></label><br />
	    <label><input type="radio" name="mode" id="modeadd" value="1" checked="checked" /> <?php echo $hesklang['madd']; ?></label>
I will add a setting in 2.2 for this.

Posted: Tue Aug 11, 2009 1:45 pm
by SEEKNDESTROY427
Thanks for the code, it's greatly appreciated. I'm using yours instead of the modification I posted.