Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function quote(postid, author, commentarea, commentID) {
- try {
- var editor_html = document.getElementById('bbp_reply_content-html');
- switchEditors.switchto(editor_html);
- // If you don't want quotes begin with "<author>:", uncomment the next line
- //author = null;
- // begin code
- var posttext = '';
- if (window.getSelection){
- posttext = window.getSelection();
- }
- else if (document.getSelection){
- posttext = document.getSelection();
- }
- else if (document.selection){
- posttext = document.selection.createRange().text;
- }
- else {
- return true;
- }
- if (posttext=='') { // quoting entire comment
- // quoteing the entire thing
- var selection = false;
- var commentID = commentID.split("q-")[1];
- //var commentID = "bbp-reply-content";
- // quote entire comment as html
- var theQuote = "q-"+commentID;
- //var theQuote = "div-comment-"+commentID;
- var posttext = document.getElementById(theQuote).innerHTML;
- // remove nested divs
- var posttext = posttext.replace(/<div(.*?)>((.|\n)*?)(<\/div>)/ig, "");
- // remove nested blockquotes
- var posttext = posttext.replace(/<blockquote(.*?)>((.|\n)*?)(<\/blockquote>)/ig, "");
- var posttext = posttext.replace(/<blockquote(.*?)>((.|\n)*?)(<\/blockquote>)/ig, "");
- // remove superfluous linebreaks
- var posttext = posttext.replace(/\s\s/gm, "");
- // do basic cleanups
- var posttext = posttext.replace(/ /g, "");
- //var posttext = posttext.replace(/<p>/g, "\n");
- //var posttext = posttext.replace(/<\/\s*p>/g, "");
- var posttext = posttext.replace(/<p>/g, "");
- var posttext = posttext.replace(/<\/\s*p>/g, "\n\n");
- var posttext = posttext.replace(/<br>/g, "")
- // remove nonbreaking space
- var posttext = posttext.replace(/ /g, " ");
- // remove nested spans
- var posttext = posttext.replace(/<span(.*?)>((.|\n)*?)(<\/span>)/ig, "");
- // remove nested blockquotes
- while (posttext != (posttext = posttext.replace(/<blockquote>[^>]*<\/\s*blockquote>/g, "")));
- // remove nested quote links
- var posttext = posttext.replace(/<a class="bbpress_quotes__link"(.*?)>((.|\n)*?)(<\/a>)/ig, "");
- //var posttext = posttext.replace(/<a class="comment_reply_link"(.*?)>((.|\n)*?)(<\/a>)/ig, "");
- }
- // build quote
- //if (author) {
- // prevent xss stuff
- author = jsEncode(author);
- var quote='\n<blockquote cite="comment-'+postid+'">\n\n<strong><a href="#comment-'+postid+'">'+unescape(author)+'</a></strong>: '+posttext+'</blockquote> \n';
- //} else {
- //var quote='\n<blockquote cite="comment-'+postid+'">\n\n'+posttext+'</blockquote>\n';
- //}
- // send quoted content
- //if (mce == true) { // TinyMCE detected
- //addQuoteMCE(comment,quote);
- //insertHTML(quote);
- //insertHTML("<p> </p>");
- //} else { // No TinyMCE detected
- var comment=document.getElementById(commentarea);
- addQuote(comment,quote);
- //}
- var editor_html = document.getElementById('bbp_reply_content-tmce');
- switchEditors.switchto(editor_html);
- return false;
- } catch (e) {
- alert("Uh Oh! Something went wrong!")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement