Add a comment via ajax and insert the comment into the comment tree.
171130
function addComment(form) {
    var node_id = form.find('input[name="node"]').val();
    var parent_id = form.find('input[name="parent"]').val();
    var text = form.find('textarea[name="comment"]').val();
    var proposal = form.find('textarea[name="proposal"]').val();

    if (text == '') {
      showError('Please enter a comment.');
      return;
    }

    // Disable the form that is being submitted.
    form.find('textarea,input').attr('disabled', 'disabled');

    // Send the comment to the server.
    $.ajax({
      type: "POST",
      url: opts.addCommentURL,
      dataType: 'json',
      data: {
        node: node_id,
        parent: parent_id,
        text: text,
        proposal: proposal
      },
      success: function(data, textStatus, error) {
        // Reset the form.
        if (node_id) {
          hideProposeChange(node_id);
        }
        form.find('textarea')
          .val('')
          .add(form.find('input'))
          .removeAttr('disabled');
	var ul = $('#cl' + (node_id || parent_id));
        if (ul.data('empty')) {
          $(ul).empty();
          ul.data('empty', false);
        }
        insertComment(data.comment);
        var ao = $('#ao' + node_id);
        ao.find('img').attr({'src': opts.commentBrightImage});
        if (node_id) {
          // if this was a "root" comment, remove the commenting box
          // (the user can get it back by reopening the comment popup)
          $('#ca' + node_id).slideUp();
        }
      },
      error: function(request, textStatus, error) {
        form.find('textarea,input').removeAttr('disabled');
        showError('Oops, there was a problem adding the comment.');
      }
    });
  }
131313
public static void addComment(TapElement element, String comment) {
        if (comment != null && comment.trim().length() > 0) {
            element.setComment(new Comment(comment, true));
        }
    }
347437
def comment(self, text, comment_prefix='#'):
        
        comment = Comment(self._container)
        if not text.startswith(comment_prefix):
            text = "{} {}".format(comment_prefix, text)
        if not text.endswith('\n'):
            text = "{}{}".format(text, '\n')
        comment.add_line(text)
        self._container.structure.insert(self._idx, comment)
        self._idx += 1
        return self
50567
def files_comments_add(self, *, comment: str, file: str, **kwargs) -> SlackResponse:
        
        kwargs.update({"comment": comment, "file": file})
        return self.api_call("files.comments.add", json=kwargs)
1198711
def _add_comments(self, comments, original_string=""):
        
        return comments and "{0}  # {1}".format(self._strip_comments(original_string)[0],
                                                "; ".join(comments)) or original_string
62361
public void addInlineComment(Element element, Content htmltree) {
        addCommentTags(element, utils.getFullBody(element), false, false, htmltree);
    }
297096
def insert(self, idx, w, comment=''):
        ''''''
        if idx >= self.count():
            self.add(w, comment)
            return
        if idx < 0:
            return
        w = copy.copy(w)
        if comment:
            w.comment = comment
        w.seq = idx
        self.wpoints.insert(idx, w)
        self.last_change = time.time()
        self.reindex()
233443
def addcomment(self, comment, private=False):
        
        # Note: fedora bodhi uses this function
        vals = self.bugzilla.build_update(comment=comment,
                                          comment_private=private)
        log.debug("addcomment: update=%s", vals)

        return self.bugzilla.update_bugs(self.bug_id, vals)
582019
def _add_comments(
        self,
        comments: Optional[Sequence[str]],
        original_string: str = ""
    ) -> str:
        
        if self.config['ignore_comments']:
            return self._strip_comments(original_string)[0]

        if not comments:
            return original_string
        else:
            return "{0}{1} {2}".format(self._strip_comments(original_string)[0],
                                       self.config['comment_prefix'],
                                       "; ".join(comments))
508598
def create_comment_edit(self, ):
        
        pte = JB_PlainTextEdit(parent=self)
        pte.set_placeholder("Enter a comment before saving...")
        pte.setMaximumHeight(120)
        return pte
132158
protected void addComment(Element member, Content htmltree) {
        if (!utils.getFullBody(member).isEmpty()) {
            writer.addInlineComment(member, htmltree);
        }
    }
1365708
def add_comment(self, page_id, text):
        
        data = {'type': 'comment',
                'container': {'id': page_id, 'type': 'page', 'status': 'current'},
                'body': {'storage': {'value': text, 'representation': 'storage'}}}
        return self.post('rest/api/content/', data=data)
176795
public void addInlineComment(Element element, DocTree tag, Content htmltree) {
        CommentHelper ch = utils.getCommentHelper(element);
        List<? extends DocTree> description = ch.getDescription(configuration, tag);
        addCommentTags(element, tag, description, false, false, htmltree);
    }
376696
def create_comment(comment)
      post_params = {
        :body => comment.post_json,
        :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})
      }

      response = Logan::Client.post "/projects/#{@project_id}/todos/#{@id}/comments.json", post_params
      Logan::Comment.new response
    end
918190
private static StringBuffer doAppendComment(StringBuffer buffer, String comment)
	{
		buffer.append(SEQUENCE__COMMENT__OPEN).append(comment).append(SEQUENCE__COMMENT__CLOSE);
		return buffer;
	}
177958
public function addComment()
    {
        $userIsAllowed = $this
            ->userCredentialsProvider
            ->isAllowed();
        if (!$userIsAllowed) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'The user is not allowed to post a comment',
            ], 401);
        }

        $sourceUUID = $this->getSourceUUID();
        if (empty($sourceUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Source UUID header must be defined',
            ], 400);
        }

        $authorUUID = $this
            ->userCredentialsProvider
            ->getUUID();
        if (empty($authorUUID)) {
            return new JsonResponse([
                'status' => 'Error',
                'message' => 'Author UUID header must be defined',
            ], 400);
        }

        $now = new DateTime();
        $postParameterBag = $this
            ->request
            ->request;

        $authorIsModerator = $this->userCredentialsProvider->isModerator();
        $authorRole = $authorIsModerator
            ? Author::ROLE_MODERATOR
            : Author::ROLE_USER;

        $state = $authorIsModerator
            ? State::APPROVED
            : State::NEW;

        $comment = Comment::createFromArray([
            'id' => bin2hex(random_bytes(32)),
            'source' => $sourceUUID,
            'author_uuid' => $authorUUID,
            'author_name' => $this->userCredentialsProvider->getName(),
            'author_email' => $this->userCredentialsProvider->getEmail(),
            'author_avatar' => $this->userCredentialsProvider->getAvatar(),
            'author_role' => $authorRole,
            'content' => $postParameterBag->get('content'),
            'created_at' => $now->format(DATE_ATOM),
            'state' => $state,
            'rating' => (int) $postParameterBag->get('rating', 0),
        ]);

        $this
            ->commentRepository
            ->addComment($comment);
        $this->flushRepository();
        $comment->setEditable(true);

        return new JsonResponse([
            'status' => 'OK',
            'comment' => $comment->toArray(),
            'user' => $this->userCredentialsProvider->toArray(),
        ], 200);
    }
881791
def create_comment(self, post_id, body):
        
        path = '/msg/create_comment'
        req = ET.Element('request')
        comment = ET.SubElement(req, 'comment')
        ET.SubElement(comment, 'post-id').text = str(int(post_id))
        ET.SubElement(comment, 'body').text = str(body)
        return self._request(path, req)