<commit_before>$('document').ready(function(e){
  function dispalyitem(e)
  {
    var items = [];
    $.getJSON('/products',function(data){
      console.log( "success" );
      items.push('<div id="maindiv">');
      $.each(data, function( key, val ) {
                items.push('<div class="alert alert-info"> \
                <button id='+val.id+' type="button" class="btn btn-default pull-right">X</button> \
                <h4 > <strong id="s1"> ' + val.additem + '</strong><button id="btn1" type="button" class="btn btn-primary pull-right">$'+ val.price+'</button> </h4> \
                <p id="p1">'+ val.description+'</p>\
                </div>');
        $('<div>', { html: items.join( "" )}).appendTo("#d1");
      });
      items.push('</div>');
    })
  };
  dispalyitem(e);
  
  //append data on current page
  
    $("#add").on('click',function(e){
    e.preventDefault();
    var x={
      additem: $("#additem").val(),
      description: $("#description").val(),
      price:$("#price").val(),
      
    };
    console.log(x);
        $.ajax({
            url : "/products",
            type : "post",      
            data : x,
      success : function(result){
        console.log(result);
                var additem1=result.additem;
        var desc1=result.description;
        var price1=result.price;        
        $("#d1").append('<div><div class="alert alert-info"> \
                <button id='+result.id+' type="button" class="btn btn-default pull-right">X</button> \
                <h4 > <strong id="s1"> ' + additem1 + '</strong><button id="btn1" type="button" class="btn btn-primary pull-right"> $'+ price1+'</button> </h4> \
                <p id="p1">'+ desc1+'</p>\
                </div></div>');
      $("#additem").val("");
      $("#description").val("");
      $("#price").val("");
            }
        });
    });
  
  //delete data
  $("div").on('click','.btn-default',function(e){
    var c=confirm("Are you sure you want to delete the item?");
    if(c === true)
    {
      var deleteitem=$(this).prop('id');
      console.log(deleteitem);
      var deleteitem2=$(this).closest('div.alert');
      console.log(deleteitem2);
      $.ajax({
        url : '/products/'+deleteitem,
        type : "DELETE",
        data : {"id":deleteitem},
        success : function(){
          console.log($(this));
          deleteitem2.remove();       
        }
      });
    }
        
    });
});<commit_msg>no message<commit_after>$('document').ready(function(e){
  function dispalyitem(e)
  {
    var items = [];
    $.getJSON('/products',function(data){
      console.log( "success" );
      items.push('<div id="maindiv">');
      $.each(data, function( key, val ) {
                items.push('<div class="alert alert-info"> \
                <button id='+val.id+' type="button" class="btn btn-default pull-right">X</button> \
                <h4 > <strong>' + val.additem + '</strong><button type="button" class="btn btn-primary pull-right">$'+ val.price+'</button> </h4> \
                <p>'+ val.description+'</p>\
                </div>');
        $('<div>', { html: items.join( "" )}).appendTo("#d1");
      });
      items.push('</div>');
    })
  };
  dispalyitem(e);
  
  //append data on current page
  
    $("#add").on('click',function(e){
    e.preventDefault();
    var x={
      additem: $("#additem").val(),
      description: $("#description").val(),
      price:$("#price").val(),
      
    };
    console.log(x);
        $.ajax({
            url : "/products",
            type : "post",      
            data : x,
      success : function(result){
        console.log(result);
                var additem1=result.additem;
        var desc1=result.description;
        var price1=result.price;        
        $("#d1").append('<div><div class="alert alert-info"> \
                <button id='+result.id+' type="button" class="btn btn-default pull-right">X</button> \
                <h4 > <strong> ' + additem1 + '</strong> <button type="button" class="btn btn-primary pull-right"> $'+ price1+'</button> </h4> \
                <p>'+ desc1+'</p>\
                </div></div>');
      $("#additem").val("");
      $("#description").val("");
      $("#price").val("");
            }
        });
    });
  
  //delete data
  $("div").on('click','.btn-default',function(e){
    var c=confirm("Are you sure you want to delete the item?");
    if(c === true)
    {
      var deleteitem=$(this).prop('id');
      console.log(deleteitem);
      var deleteitem2=$(this).closest('div.alert');
      console.log(deleteitem2);
      $.ajax({
        url : '/products/'+deleteitem,
        type : "DELETE",
        data : {"id":deleteitem},
        success : function(){
          console.log($(this));
          deleteitem2.remove();       
        }
      });
    }
        
    });
});
{'fraction_non_alphanumeric': 0.21621621621621623, 'fraction_numerical': 0.007427274602847122, 'mean_word_length': 2.0074441687344913, 'pattern_counts': {'":': 2, '<': 61, '<?xml version=': 0, '>': 61, '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': '5928154', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1497, 'n_words': 268}