Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // initializeComment blanks out the comment title and the comment author, sets the comment
- // body to the given text, focuses the comment body, resizes the comment height to show
- // all of the given text, and puts the cursor at the end of the comment body.
- function initializeComment(text) {
- document.getElementById("comment_jebra").value = ""; // Title.
- document.getElementById("comment_comment_writer").value = ""; // Author.
- commentBody = document.getElementById("comment_argle"); // Body.
- window.location.href = "#post-comment"
- commentBody.focus();
- commentBody.value = text;
- autogrow()
- }
- function reply(commentNum) {
- initializeComment("#" + commentNum + " ");
- }
- function quote(commentNum) {
- reply("")
- var body = "";
- // Find the outer element for the comment to be quoted and get its child of class
- // "comment-body". (There should be only one.) The innerText of this is what we want to
- // quote.
- var comment = document.getElementById(commentNum);
- for (var i = 0; i < comment.childNodes.length; i++) {
- if (comment.childNodes[i].className == "comment-body") {
- text = comment.childNodes[i].innerText.replace(/^(?=.)/mg, "> ");
- // Append a final pair of newlines if necessary.
- if (text.slice(-2) != "\n\n") {
- text = text + "\n\n";
- }
- initializeComment(text);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement