<commit_before>var COMMENT_DEBUG = false;
function logger(log) {
  if (COMMENT_DEBUG) {
    console.log(log);
  }
}

localStorage.clear();
logger("Code for Gene Comment is loaded");
var geid = $('#gene_stable_id').attr('data-value');
var isCmtAdm = $('#comment-admin-page-id').length;


$('#cm9012').click(function() {
  logger("Submit button is clicked. Going to make AJAX!!" + geid);
  var species = window.location.pathname.split('/')[1];
  var content = lineBreakFormat($('.content_input').val());
    $.post(window.location.origin + "/Multi/Account/Comment/Add",
    {
        cmt: content,
        geid: geid,
        spec: species
    },
    function(data, status, xhr){
        //alert("Data: " + data + "\nStatus: " + status);
        if (xhr.status==200 && data.saved) {
          alert("Comment added");
        } else {
          alert("There is an error adding your comment");
        }
        $('.content_input').val("");
        fetch_comment();
    });
});


function fetch_comment() {
  $.get(window.location.origin + "/Multi/Account/Comment/Get",
  {
    geid: geid
  },
  function(data, status){
    $('#cmt_section1').empty();
    for (var i=0; i<data.length; i++) {
      var item = data[i];            
      $('#cmt_section1').append(comment_box(item.user, item.timestamp, item.comment_data, item.uuid, item.isEditable, item.wasEdited));
    }
  });
}

function lineBreakFormat(message){
  return message.replace(/\r?\n/g,"<br>");
}

function reFormat(message) {
  var mymessage = message.replace(/<b>/g, 'TAG0001').replace(/<\/b>/g, 'TAGC0001')
                          .replace(/<i>/g, 'TAG0002').replace(/<\/i>/g, 'TAGC0002')
                          .replace(/<br>/g, 'TAG0003')
                          .replace(/(&nbsp;|<([^>]+)>)/ig, "")
                          .replace(/TAG0001/g, '<b>').replace(/TAGC0001/g, '</b>')
                          .replace(/TAG0002/g, '<i>').replace(/TAGC0002/g, '</i>')
                          .replace(/TAG0003/g, '<br>')
                          ;
  logger(mymessage);<commit_msg>Refresh comment count on change<commit_after>var COMMENT_DEBUG = false;
function logger(log) {
  if (COMMENT_DEBUG) {
    console.log(log);
  }
}

localStorage.clear();
logger("Code for Gene Comment is loaded");
var geid = $('#gene_stable_id').attr('data-value');
var isCmtAdm = $('#comment-admin-page-id').length;


$('#cm9012').click(function() {
  logger("Submit button is clicked. Going to make AJAX!!" + geid);
  var species = window.location.pathname.split('/')[1];
  var content = lineBreakFormat($('.content_input').val());
    $.post(window.location.origin + "/Multi/Account/Comment/Add",
    {
        cmt: content,
        geid: geid,
        spec: species
    },
    function(data, status, xhr){
        //alert("Data: " + data + "\nStatus: " + status);
        if (xhr.status==200 && data.saved) {
          alert("Comment added");
        } else {
          alert("There is an error adding your comment");
        }
        $('.content_input').val("");
        fetch_comment();
    });
});


function fetch_comment() {
  $.get(window.location.origin + "/Multi/Account/Comment/Get",
  {
    geid: geid
  },
  function(data, status, xhr){
    if (xhr.status != 200) return;
    $('#cmt_section1').empty();
    for (var i=0; i<data.length; i++) {
      var item = data[i];            
      $('#cmt_section1').append(comment_box(item.user, item.timestamp, item.comment_data, item.uuid, item.isEditable, item.wasEdited));
    }
    updateCount(data.length);
  });
}

function updateCount(count) {
  var text = 'User Comment (' + count + ')';
  $("#page_nav [title^='User Comment']").text(text);
  $(".nav-heading h1.caption").text(text);
}

function lineBreakFormat(message){
  return message.replace(/\r?\n/g,"<br>");
}

function reFormat(message) {
  var mymessage = message.replace(/<b>/g, 'TAG0001').replace(/<\/b>/g, 'TAGC0001')
                          .replace(/<i>/g, 'TAG0002').replace(/<\/i>/g, 'TAGC0002')
                          .replace(/<br>/g, 'TAG0003')
                          .replace(/(&nbsp;|<([^>]+)>)/ig, "")
                          .replace(/TAG0001/g, '<b>').replace(/TAGC0001/g, '</b>')
                          .replace(/TAG0002/g, '<i>').replace(/TAGC0002/g, '</i>')
                          .replace(/TAG0003/g, '<br>')
                          ;
  logger(mymessage);
{'fraction_non_alphanumeric': 0.20032051282051283, 'fraction_numerical': 0.024267399267399268, 'mean_word_length': 2.4, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6419049', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1421, 'n_words': 253}