docs/_static/websupport.js
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.');
      }
    });
  }
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.');
      }
    });
  }
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.' ) ; } } ) ; }
Add a comment via ajax and insert the comment into the comment tree.
Add a comment via ajax and insert the comment into the comment tree .