Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Site Bugs / Suggestions
  4. Quoting

Quoting

Scheduled Pinned Locked Moved Site Bugs / Suggestions
businesstoolsquestion
15 Posts 5 Posters 19 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Thomas Freudenberg

    Chris, how about a Reply with quote button. Many times when editing a reply you will quote the previous posting, so an automatism would be very helpful. I suggest following format:


    Thomas Freudenberg wrote:
    Chris, how about a Reply with quote button. Many times when editing a reply you will quote the previous posting, so an automatism would be very helpful. I suggest following format:


    <blockquote><hr><small>
    <b><a href="/script/profile/whos_who.asp?id=4960" target="_blank">Thomas Freudenberg</a> wrote:</b>
    <br>
    Chris, how about a <i>Reply with quote</i> button. Many times when editing
    a reply you will quote the previous posting, so an automatism would be very helpful. I
    suggest following format:
    </small><hr></blockquote>

    Regards Thomas


    Disclaimer:
    Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.

    M Offline
    M Offline
    Michael P Butler
    wrote on last edited by
    #2

    I don't know if that is a good thing. Having it quote the entire message would lead to a lot of having to read through the same comments a lot of times in the different messages. I prefer just to quote the relevant part I'm replying to. Imagine the last message in a thread having the entire message made up of the entire thread plus a me too response. Michael :-)

    T 1 Reply Last reply
    0
    • M Michael P Butler

      I don't know if that is a good thing. Having it quote the entire message would lead to a lot of having to read through the same comments a lot of times in the different messages. I prefer just to quote the relevant part I'm replying to. Imagine the last message in a thread having the entire message made up of the entire thread plus a me too response. Michael :-)

      T Offline
      T Offline
      Thomas Freudenberg
      wrote on last edited by
      #3

      Michael P Butler wrote:
      I prefer just to quote the relevant part I'm replying to.


      And so I do ;) I know that trusting in the user's discipline to quote relevant parts only is too naive. Of course we must find a compromise between easy quoting and completely quoted threads. Regards Thomas


      Disclaimer:
      Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.

      P 1 Reply Last reply
      0
      • T Thomas Freudenberg

        Michael P Butler wrote:
        I prefer just to quote the relevant part I'm replying to.


        And so I do ;) I know that trusting in the user's discipline to quote relevant parts only is too naive. Of course we must find a compromise between easy quoting and completely quoted threads. Regards Thomas


        Disclaimer:
        Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.

        P Offline
        P Offline
        Paul Watson
        wrote on last edited by
        #4

        Why not have it so that the user has to highlight the text they want to quote and then click a Quote button which inserts the highlighted text with the Quote formatting into the text box. If they don't highlight any text then nothing happens when they click the button (or it pops up a message saying "Highlight some text, please"). regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

        C 1 Reply Last reply
        0
        • P Paul Watson

          Why not have it so that the user has to highlight the text they want to quote and then click a Quote button which inserts the highlighted text with the Quote formatting into the text box. If they don't highlight any text then nothing happens when they click the button (or it pops up a message saying "Highlight some text, please"). regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

          C Offline
          C Offline
          Chris Maunder
          wrote on last edited by
          #5

          If you can work out the javascript that copies the selected text and pastes it into the edit window then you're a better man than I! (spent many hours trying to do exactly this - am I missing something simple?) cheers, Chris Maunder (CodeProject)

          P M 2 Replies Last reply
          0
          • C Chris Maunder

            If you can work out the javascript that copies the selected text and pastes it into the edit window then you're a better man than I! (spent many hours trying to do exactly this - am I missing something simple?) cheers, Chris Maunder (CodeProject)

            P Offline
            P Offline
            Paul Watson
            wrote on last edited by
            #6

            If you can work out the javascript that copies the selected text and pastes it into the edit window then you're a better man than I! You should not set yourself up like that because... Tada! Get selected text example The trick is not so simple. Basically you have to create a textRange object and then pull the value from there. Here is an example (very simple and quick):

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
            <html>
            <head>
            <title>Untitled</title>
            <script language="JavaScript">
            function getSel()
            {
            if (document.getSelection) txt = document.getSelection();
            else if (document.selection) txt = document.selection.createRange().text;
            else return;
            if (txt !== ""){
            txtReply.value = "<HR><I>" + txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ") + "</I><HR>";
            }
            else
            {
            alert('You must please select some text to quote');
            }
            }
            </script>
            </head>

            <body>
            <DIV id="divOriginalPost">This is the original post, select some text and then click the quote button</DIV>
            <TEXTAREA id="txtReply" COLS="40" ROWS="10"></TEXTAREA>
            <INPUT type="Button" onclick="getSel()" id="cmdQuote" value="Quote">

            </body>
            </html>

            It can be made to work in Netscape. We had to do this for an intranet project and it was a pain to figure out. Luckily that link I posted above helped a lot :) I still don't feel a better man than you though. :laugh: regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

            C 1 Reply Last reply
            0
            • C Chris Maunder

              If you can work out the javascript that copies the selected text and pastes it into the edit window then you're a better man than I! (spent many hours trying to do exactly this - am I missing something simple?) cheers, Chris Maunder (CodeProject)

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #7

              Here's code that will append the current selection to the end of the textarea's contents. I couldn't figure out how to insert it at the current caret position (or even how to get the caret position). Button1 = your Paste button, Text1 = the text box.

              function Button1_onclick() {
              var seltext = document.selection.createRange().text;
              if ( seltext != "" )
              Text1.value += seltext;
              }

              --Mike-- http://home.inreach.com/mdunn/ #include "witty_sig.h" :love: your :bob: with :vegemite: and :beer:

              P 1 Reply Last reply
              0
              • M Michael Dunn

                Here's code that will append the current selection to the end of the textarea's contents. I couldn't figure out how to insert it at the current caret position (or even how to get the caret position). Button1 = your Paste button, Text1 = the text box.

                function Button1_onclick() {
                var seltext = document.selection.createRange().text;
                if ( seltext != "" )
                Text1.value += seltext;
                }

                --Mike-- http://home.inreach.com/mdunn/ #include "witty_sig.h" :love: your :bob: with :vegemite: and :beer:

                P Offline
                P Offline
                Paul Watson
                wrote on last edited by
                #8

                I couldn't figure out how to insert it at the current caret position (or even how to get the caret position). I noticed that when inserting emoticons on CP it also just puts it at the end of the text, not where the cursor is. However, seeing as focus is passed to the Quote button would there be a cursor (caret) position to get? I guess onblur of the textbox you could record the last caret position and use that. Then when you click the Quote button it uses the caret variable as the position... hmmm might work. brb, trying it out :-D regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

                C 1 Reply Last reply
                0
                • P Paul Watson

                  I couldn't figure out how to insert it at the current caret position (or even how to get the caret position). I noticed that when inserting emoticons on CP it also just puts it at the end of the text, not where the cursor is. However, seeing as focus is passed to the Quote button would there be a cursor (caret) position to get? I guess onblur of the textbox you could record the last caret position and use that. Then when you click the Quote button it uses the caret variable as the position... hmmm might work. brb, trying it out :-D regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

                  C Offline
                  C Offline
                  Chris Maunder
                  wrote on last edited by
                  #9

                  Paul Watson wrote: I guess onblur of the textbox you could record the last caret position and use that. Then when you click the Quote button it uses the caret variable as the position... hmmm might work. brb, trying it out Any luck? cheers, Chris Maunder (CodeProject)

                  P 1 Reply Last reply
                  0
                  • P Paul Watson

                    If you can work out the javascript that copies the selected text and pastes it into the edit window then you're a better man than I! You should not set yourself up like that because... Tada! Get selected text example The trick is not so simple. Basically you have to create a textRange object and then pull the value from there. Here is an example (very simple and quick):

                    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                    <html>
                    <head>
                    <title>Untitled</title>
                    <script language="JavaScript">
                    function getSel()
                    {
                    if (document.getSelection) txt = document.getSelection();
                    else if (document.selection) txt = document.selection.createRange().text;
                    else return;
                    if (txt !== ""){
                    txtReply.value = "<HR><I>" + txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ") + "</I><HR>";
                    }
                    else
                    {
                    alert('You must please select some text to quote');
                    }
                    }
                    </script>
                    </head>

                    <body>
                    <DIV id="divOriginalPost">This is the original post, select some text and then click the quote button</DIV>
                    <TEXTAREA id="txtReply" COLS="40" ROWS="10"></TEXTAREA>
                    <INPUT type="Button" onclick="getSel()" id="cmdQuote" value="Quote">

                    </body>
                    </html>

                    It can be made to work in Netscape. We had to do this for an intranet project and it was a pain to figure out. Luckily that link I posted above helped a lot :) I still don't feel a better man than you though. :laugh: regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #10

                    Thanks Paul, thanks Mike! The quote button is in. cheers, Chris Maunder (CodeProject)

                    P 1 Reply Last reply
                    0
                    • C Chris Maunder

                      Thanks Paul, thanks Mike! The quote button is in. cheers, Chris Maunder (CodeProject)

                      P Offline
                      P Offline
                      Paul Watson
                      wrote on last edited by
                      #11

                      *highlight text* *click quote* Chris Maunder wrote: Thanks Paul, thanks Mike! The quote button is in. Ooooohhhhh :) Now all we need is a "Generate rational, intelligent and rallying counter arguement" button... :-D regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        Paul Watson wrote: I guess onblur of the textbox you could record the last caret position and use that. Then when you click the Quote button it uses the caret variable as the position... hmmm might work. brb, trying it out Any luck? cheers, Chris Maunder (CodeProject)

                        P Offline
                        P Offline
                        Paul Watson
                        wrote on last edited by
                        #12

                        Chris Maunder wrote: Any luck? Here it is Chris. Once again not all my work, got it from FAQTs - Knowledge Base. I took your new Quote code and put in the other code. Once again it uses the TextRange object and then the CharAt method. You may have to do a few more tests than I did on recording the caret position from the TEXTAREA as I have only covered OnClick and OnKeyPress. (Avoid the OnBlur, something odd happens) You could also use the functions for inserting the Emoticons! That would be nice :-D

                        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                        <html>
                        <head>
                        <title>Untitled</title>
                        </head>
                        <script language='JavaScript'>
                        <!--
                        function QuoteText(author)
                        {
                        var txt = "";
                        if (document.getSelection) txt = document.getSelection();
                        else if (document.selection) txt = document.selection.createRange().text;
                        else return;

                        var emph = false;
                        emph = true
                        var TextArea = txtReply;
                        if (txt !== "") {
                        	var text = "";
                        	//var text = TextArea.value;
                        	var length = text.length;
                        	if (length > 0 && text.charAt(length-1) != "\\n") text += "\\n\\n";
                        	
                        	text += (author + " wrote:\\n");
                        	if (emph) text += "<i>";
                        	text += txt;
                        	if (emph) text += "</i>";
                        	text += "\\n\\n";
                        	
                        	insertAtCaret(TextArea, text);
                        	
                        	TextArea.focus();
                        }
                        else
                        	alert('You did not select any text to quote');
                        

                        }

                        function storeCaret (textEl)
                        {
                        if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
                        }

                        function insertAtCaret (textEl, text)
                        {
                        if (textEl.createTextRange && textEl.caretPos)
                        {
                        var caretPos = textEl.caretPos;
                        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
                        }
                        else textEl.value = text;
                        }
                        //-->
                        </script>

                        <body>
                        <DIV id="divOriginal" style="padding: 5px; width: 400px; border: 1px solid #cccccc">
                        Colin Davies wrote:
                        Yeah the quote button is a cool idea<BR><BR>

                        	Thank Paul Watson and Mike Dunn for the kick in the bum to get this feature added.<BR><BR>
                        
                        	cheers,<BR>
                        	Chris Maunder (CodeProject)
                        </DIV>
                        <BR><INPUT type="Button" name="cmdQuote" value="Quote that!" onclick="QuoteText('Bob');"><BR><BR>
                        <TEXTAREA name="txtReply" id="txtReply" 
                        	rows="20" cols="47" 
                        	style="width: 400px;" 
                        	onclick="storeCaret(this);"
                        
                        C 1 Reply Last reply
                        0
                        • P Paul Watson

                          Chris Maunder wrote: Any luck? Here it is Chris. Once again not all my work, got it from FAQTs - Knowledge Base. I took your new Quote code and put in the other code. Once again it uses the TextRange object and then the CharAt method. You may have to do a few more tests than I did on recording the caret position from the TEXTAREA as I have only covered OnClick and OnKeyPress. (Avoid the OnBlur, something odd happens) You could also use the functions for inserting the Emoticons! That would be nice :-D

                          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                          <html>
                          <head>
                          <title>Untitled</title>
                          </head>
                          <script language='JavaScript'>
                          <!--
                          function QuoteText(author)
                          {
                          var txt = "";
                          if (document.getSelection) txt = document.getSelection();
                          else if (document.selection) txt = document.selection.createRange().text;
                          else return;

                          var emph = false;
                          emph = true
                          var TextArea = txtReply;
                          if (txt !== "") {
                          	var text = "";
                          	//var text = TextArea.value;
                          	var length = text.length;
                          	if (length > 0 && text.charAt(length-1) != "\\n") text += "\\n\\n";
                          	
                          	text += (author + " wrote:\\n");
                          	if (emph) text += "<i>";
                          	text += txt;
                          	if (emph) text += "</i>";
                          	text += "\\n\\n";
                          	
                          	insertAtCaret(TextArea, text);
                          	
                          	TextArea.focus();
                          }
                          else
                          	alert('You did not select any text to quote');
                          

                          }

                          function storeCaret (textEl)
                          {
                          if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
                          }

                          function insertAtCaret (textEl, text)
                          {
                          if (textEl.createTextRange && textEl.caretPos)
                          {
                          var caretPos = textEl.caretPos;
                          caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
                          }
                          else textEl.value = text;
                          }
                          //-->
                          </script>

                          <body>
                          <DIV id="divOriginal" style="padding: 5px; width: 400px; border: 1px solid #cccccc">
                          Colin Davies wrote:
                          Yeah the quote button is a cool idea<BR><BR>

                          	Thank Paul Watson and Mike Dunn for the kick in the bum to get this feature added.<BR><BR>
                          
                          	cheers,<BR>
                          	Chris Maunder (CodeProject)
                          </DIV>
                          <BR><INPUT type="Button" name="cmdQuote" value="Quote that!" onclick="QuoteText('Bob');"><BR><BR>
                          <TEXTAREA name="txtReply" id="txtReply" 
                          	rows="20" cols="47" 
                          	style="width: 400px;" 
                          	onclick="storeCaret(this);"
                          
                          C Offline
                          C Offline
                          Chris Maunder
                          wrote on last edited by
                          #13

                          Thanks Paul! I had a go at this but it didn't seem to be consistently saving the carrot position. I'll have a second attempt later. cheers, Chris Maunder (CodeProject)

                          P 1 Reply Last reply
                          0
                          • C Chris Maunder

                            Thanks Paul! I had a go at this but it didn't seem to be consistently saving the carrot position. I'll have a second attempt later. cheers, Chris Maunder (CodeProject)

                            P Offline
                            P Offline
                            Paul Watson
                            wrote on last edited by
                            #14

                            Hmmm, in what instances doesn't it record the caret position? I will have a look at it and fiddle. (lame joke alert!) I may call Bugs Bunny, he is good with carrots... X| Chris Maunder wrote: cheers, Chris Maunder (CodeProject) Damn I like clicking that button... :-D regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

                            C 1 Reply Last reply
                            0
                            • P Paul Watson

                              Hmmm, in what instances doesn't it record the caret position? I will have a look at it and fiddle. (lame joke alert!) I may call Bugs Bunny, he is good with carrots... X| Chris Maunder wrote: cheers, Chris Maunder (CodeProject) Damn I like clicking that button... :-D regards, Paul Watson Bluegrass Cape Town, South Africa Do you Sonork? I do! 100.9903 Stormfront "The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

                              C Offline
                              C Offline
                              Chris Maunder
                              wrote on last edited by
                              #15

                              I only had a brief time to play and it seemed semi-random. I'll have to sit down and really thrash it out. cheers, Chris Maunder (CodeProject)

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups