<commit_before>(function($) {

  $("#manage-product-details-button").live('click', function() {
    $("#product-price-details").find('.loading-area').addClass('small-loading');
    url = $(this).attr('href');
    $.get(url, function(data){
      $("#manage-product-details-button").hide();
      $("#display-price-details").hide();
      $("#display-manage-price-details").html(data);
      $("#product-price-details").find('.loading-area').removeClass('small-loading');
    });
    return false;
  });

  $(".cancel-price-details").live('click', function() {
    if ( !$(this).hasClass('form-changed') ) {
      cancelPriceDetailsEdition();
    } else {
      if (confirm($(this).attr('data-confirm'))) {
        cancelPriceDetailsEdition();
      }
    }
    return false;
  });

  $("#manage-product-details-form").live('submit', function(data) {
     var form = this;
     $(form).find('.loading-area').addClass('small-loading');
     $(form).css('cursor', 'progress');
     $.post(form.action, $(form).serialize(), function(data) {
       $("#display-manage-price-details").html(data);
       $("#manage-product-details-button").show();
     });
     if ($('#progressbar-icon').hasClass('ui-icon-check')) {
       display_notice($('#progressbar-icon').attr('data-price-described-notice'));
     }
     return false;
  });

  $("#add-new-cost").live('click', function() {
    $('#display-product-price-details tbody').append($('#new-cost-fields tbody').html());
    return false;
  });

  $(".cancel-new-cost").live('click', function() {
    $(this).parents('tr').remove();
    calculateValuesForBar();
    return false;
  });

  $("#product-info-form").live('submit', function(data) {
    var form = this;
    updatePriceCompositionBar(form);
  });

  $("form.edit_input").live('submit', function(data) {
    var form = this;
    inputs_cost_update_url = $(form).find('#inputs-cost-update-url').val();
    $.get(inputs_cost_update_url, function(data){
      $(".inputs-cost span").html(data);
    });
    updatePriceCompositionBar(form);
    return false;
  });

  $("#manage-product-details-form .price-details-price").live('blur', function(data) { calculateValuesForBar(); });

  function cancelPriceDetailsEdition() {
    $("#manage-product-details-button").show();
    $("#display-price-details").show();
    $("#display-manage-price-details").html('');
  };

})(jQuery);

function updatePriceCompositionBar(form) {
  bar_url = jQuery(form).find('.bar-update-url').val();
  jQuery.get(bar_url, function(data){
    jQuery("#price-composition-bar").html(data);
    jQuery('form #product_price').val(currencyToFloat(jQuery('#progressbar-text .product_price').html(), currency_format.separator, currency_format.delimiter));
    jQuery('form #product_inputs_cost').val(currencyToFloat(jQuery('#display-product-price-details .inputs-cost span').html(), currency_format.separator, currency_format.delimiter, currency_format.unit));
    calculateValuesForBar();
  });
};

function enablePriceDetailSubmit() {
  jQuery('#manage-product-details-form input.submit').removeAttr("disabled").removeClass('disabled');
}

function calculateValuesForBar() {
  jQuery('.cancel-price-details').addClass('form-changed');
  var product_price = parseFloat(jQuery('form #product_price').val());
  var total_cost = parseFloat(jQuery('form #product_inputs_cost').val());

  jQuery('form .price-details-price').each(function() {
    var this_val = parseFloat(jQuery(this).val()) || 0;
    total_cost = total_cost + this_val;
  });
  enablePriceDetailSubmit();

  var described = (product_price - total_cost) == 0;
  var percentage = total_cost * 100 / product_price;
  priceCompositionBar(percentage, described, total_cost, product_price);
}<commit_msg>Deal with decimal numbers in costs<commit_after>(function($) {

  $("#manage-product-details-button").live('click', function() {
    $("#product-price-details").find('.loading-area').addClass('small-loading');
    url = $(this).attr('href');
    $.get(url, function(data){
      $("#manage-product-details-button").hide();
      $("#display-price-details").hide();
      $("#display-manage-price-details").html(data);
      $("#product-price-details").find('.loading-area').removeClass('small-loading');
    });
    return false;
  });

  $(".cancel-price-details").live('click', function() {
    if ( !$(this).hasClass('form-changed') ) {
      cancelPriceDetailsEdition();
    } else {
      if (confirm($(this).attr('data-confirm'))) {
        cancelPriceDetailsEdition();
      }
    }
    return false;
  });

  $("#manage-product-details-form").live('submit', function(data) {
     var form = this;
     $(form).find('.loading-area').addClass('small-loading');
     $(form).css('cursor', 'progress');
     $.post(form.action, $(form).serialize(), function(data) {
       $("#display-manage-price-details").html(data);
       $("#manage-product-details-button").show();
     });
     if ($('#progressbar-icon').hasClass('ui-icon-check')) {
       display_notice($('#progressbar-icon').attr('data-price-described-notice'));
     }
     return false;
  });

  $("#add-new-cost").live('click', function() {
    $('#display-product-price-details tbody').append($('#new-cost-fields tbody').html());
    return false;
  });

  $(".cancel-new-cost").live('click', function() {
    $(this).parents('tr').remove();
    calculateValuesForBar();
    return false;
  });

  $("#product-info-form").live('submit', function(data) {
    var form = this;
    updatePriceCompositionBar(form);
  });

  $("form.edit_input").live('submit', function(data) {
    var form = this;
    inputs_cost_update_url = $(form).find('#inputs-cost-update-url').val();
    $.get(inputs_cost_update_url, function(data){
      $(".inputs-cost span").html(data);
    });
    updatePriceCompositionBar(form);
    return false;
  });

  $("#manage-product-details-form .price-details-price").live('blur', function(data) { calculateValuesForBar(); });

  function cancelPriceDetailsEdition() {
    $("#manage-product-details-button").show();
    $("#display-price-details").show();
    $("#display-manage-price-details").html('');
  };

})(jQuery);

function updatePriceCompositionBar(form) {
  bar_url = jQuery(form).find('.bar-update-url').val();
  jQuery.get(bar_url, function(data){
    jQuery("#price-composition-bar").html(data);
    jQuery('form #product_price').val(currencyToFloat(jQuery('#progressbar-text .product_price').html(), currency_format.separator, currency_format.delimiter));
    jQuery('form #product_inputs_cost').val(currencyToFloat(jQuery('#display-product-price-details .inputs-cost span').html(), currency_format.separator, currency_format.delimiter, currency_format.unit));
    calculateValuesForBar();
  });
};

function enablePriceDetailSubmit() {
  jQuery('#manage-product-details-form input.submit').removeAttr("disabled").removeClass('disabled');
}

function calculateValuesForBar() {
  jQuery('.cancel-price-details').addClass('form-changed');
  var product_price = parseFloat(jQuery('form #product_price').val());
  var total_cost = parseFloat(jQuery('form #product_inputs_cost').val());

  jQuery('form .price-details-price').each(function() {
    var this_val = parseFloat(jQuery(this).val().replace(currency_format.separator, '.')) || 0;
    total_cost = total_cost + this_val;
  });
  enablePriceDetailSubmit();

  var described = (product_price - total_cost) == 0;
  var percentage = total_cost * 100 / product_price;
  priceCompositionBar(percentage, described, total_cost, product_price);
}
{'fraction_non_alphanumeric': 0.20629231381919555, 'fraction_numerical': 0.0013274923669188902, 'mean_word_length': 4.483260553129549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7375452', 'n_tokens_mistral': 2271, 'n_tokens_neox': 2244, 'n_words': 295}