Thread: Quoting posts

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Quoting posts

    First, what is multi-quote and how do I use it?

    Second, is there a way to highlight text from a post and copy it as a quote complete with the "Originally posted by <member>" title on it?

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by VirtualAce View Post
    First, what is multi-quote and how do I use it?
    On the bottom bar of each post, there are 3 icons. An arrow with the word "Reply", a quote bubble with the words "Reply With Quote" and a quote bubble with just a "+" next to it. That 3rd one is the multi-quote button. Click it. Click it in another post. That plus sign should turn to a check mark signifying you've pulled it into a multi-quote. Repeat that as many times as you want. On the last post you want to quote, click "Reply With Quote" It should pop them all into the reply box with the correct "posted by" for each one. VBulletin thinks you should be able to multi-quote from several different threads, but I haven't gotten it to work yet.

    Second, is there a way to highlight text from a post and copy it as a quote complete with the "Originally posted by <member>" title on it?
    Not that I'm aware of, but you can put the author's name in the quote tag easily enough yourself. Just put quote="author's name" in the opening tag. You can even quote man pages or the standard this way, like quote="C standard 6.7.1.1p3".

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by VirtualAce View Post
    Second, is there a way to highlight text from a post and copy it as a quote complete with the "Originally posted by <member>" title on it?
    I'd give one of my 10 fingers for this feature.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Mario F. View Post
    I'd give one of my 10 fingers for this feature.
    I'd give another one of his fingers for this feature!


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    My middle finger to quzah if we get this feature!
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Seems easy enough to implement as most browsers define a javascript method of retrieving the selected text... hopefully webmaster will look into it.
    Sent from my iPadŽ

  7. #7
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    This seems to work. Requires greasemonkey for Firefox but should work in IE if you have one of the GreaseMonkey equivalents.
    It creates a fourth button next to the Reply, Reply With Quote links.
    Quoting posts-qftext-png

    Highlight some text and click any of the buttons and it should magically appear in the quote box.

    I'm by no means a javascripter so it could probably be better implemented. If anybody wants to improve it, knock yourself out :-)

    Code:
    // ==UserScript==
    // @name Cboard quote reply-er
    // @description Quote highlighted text on cboard
    // @include http://cboard.cprogramming.com/*
    // @run-at document-end
    // ==/UserScript==
    
    window.addEventListener("load", function(e) {
       addLinks();
    }, false);
    
    //
    // From http://robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
    //
    function getElementsByClassName(oElm, strTagName, strClassName)
    {
      var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
      var arrReturnElements = new Array();
      strClassName = strClassName.replace(/\-/g, "\\-");
      var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
      var oElement;
      for(var i=0; i<arrElements.length; ++i)
      {
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className))
        {
           arrReturnElements.push(oElement);
        }
      }
      return (arrReturnElements);
    }
    function addButtonListener(name){
      var button = document.getElementById(name);
      if(button.addEventListener)
      {
         button.addEventListener('click', QuoteHighlightedText, true);
      }
    }
    
    function addLinks(){
     var postControls = getElementsByClassName(document, "span", "postcontrols");
     var numPostControls = postControls.length;
     for(var i = 0; i < numPostControls; ++i)
     {
       var thisId = 'highlightQuoter' + i;
       postControls[i].innerHTML = postControls[i].innerHTML + ' <input type="button"  value="Quote Highlighted Text" id="' + thisId + '" onclick="QuoteHighlightedText(); return false;" />';
       addButtonListener(thisId);
     }
    }
    
    function GetHighlightTextAndLocation()
    {
       var highlightedText;
       var highlightLocation;
       if (window.getSelection)
       {
          // all browsers, except IE before version 9
          var highlightedTextRange = window.getSelection();
          highlightedText = highlightedTextRange.toString();
          highlightLocation = highlightedTextRange.anchorNode;
          // firefox seems to put text into their own child nodes
          // we need the blockquote element here, so get it, if this is the case
          if(highlightLocation.parentNode.tagName == "BLOCKQUOTE")
          {
             highlightLocation = highlightLocation.parentNode;
          }
       } 
       else 
       {
          var highlightedTextRange = document.selection.createRange();
          highlightedText = highlightedTextRange.text;
          highlightLocation = highlightedTextRange.parentElement();
       }
       return {text: highlightedText, loc: highlightLocation};
    }
    
    function GetPostId(selectionLoc)
    {
       var postMessageDiv = selectionLoc.parentNode;
       var idString = postMessageDiv.id;
       var underScoreIndex = idString.lastIndexOf("_");
       return idString.substring(underScoreIndex + 1);
    }
    
    function GetParent(node, numLevels)
    {
       // firefox
       if(node.parentNode)
       {
           while(numLevels)
           {
               node = node.parentNode;
               --numLevels;
           }
       }
       // IE
       else if(node.parentElement)
       {
           while(numLevels)
           {
               node = node.parentElement;
               --numLevels;
           }
       }
       return node;
    }
    
    function NavigateFirstChildren(node, numLevels)
    {
       if(node.firstElementChild)
       {
          while(numLevels)
          {
             node = node.firstElementChild;
             --numLevels;
          }
       }
       else
       {
          while(numLevels)
          {
             node = node.firstChild;
             --numLevels;
          }
       }
       return node;
    }
    
    function GetPreviousSibling(node, num)
    {
       if(node.previousElementSibling)
       {
          while(num)
          {
              node = node.previousElementSibling;
              --num;
          }
       }
       else
       {
          while(num)
          {
              node = node.previousSibling;
              --num;
          }
       }
       return node;
    }
    
    function GetPosterNameAndId(selectionLoc)
    {
       var postBodyDiv = selectionLoc;
       var isInQuote = ((selectionLoc.className == "message") && (selectionLoc.tagName == "DIV"));
    
       if(isInQuote)
       {
           // get to the postcontext blockQuote
           postBodyDiv = GetParent(selectionLoc, 4);
       }
    
       // now get to the actual postbody div
       var postId = GetPostId(postBodyDiv);
    
       postBodyDiv = GetParent(postBodyDiv, 4);
    
       // get to the userInfo div
       var userInfoDiv = GetPreviousSibling(postBodyDiv, 1);
    
       // now go down to the user name anchor
       var userNameAnchor = NavigateFirstChildren(userInfoDiv, 4);
    
       var userName;
       if(userNameAnchor.textContent)
       {
           userName = userNameAnchor.textContent;
       }
       else
       {
           userName = userNameAnchor.innerText;
       }
    
       return {userName: userName, id: postId};
    }
    
    function QuoteHighlightedText()
    {
       var highlight = GetHighlightTextAndLocation();
       var postDetails = GetPosterNameAndId(highlight.loc);
       // the "[quote" is split up because
       // it caused a quote box in the middle of the code
       var quoteText = "[qu" + "ote=" + postDetails.userName + ";" + postDetails.id + "]" + highlight.text + "[/quote]\n";
       var postBox = document.getElementsByTagName("textarea")[1];
       if(postBox)
       {
           postBox.value = quoteText;
           postBox.focus();
       }
       else alert("Can't find the Reply box, are you logged in?");
    }
    Last edited by adeyblue; 08-01-2011 at 05:14 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ( posts per day)
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-05-2008, 12:53 AM
  2. Quoting Strings
    By xtjoeytx in forum C++ Programming
    Replies: 4
    Last Post: 08-05-2007, 04:33 PM
  3. Quoting the contents of a #define
    By octangle in forum C Programming
    Replies: 4
    Last Post: 01-10-2007, 02:40 PM
  4. Where did all the posts go?
    By webmaster in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 03-30-2006, 07:05 PM
  5. Simple question on quoting output
    By LouB in forum C++ Programming
    Replies: 13
    Last Post: 06-16-2002, 02:57 PM