<commit_before>var timeoutID1;
var timeoutID2;

/**
 * Prints the given error message.
 * @param {string} msg - The error message to print.
 */
function error(msg) {  // eslint-disable-line no-unused-vars
  if (timeoutID1) {
    window.clearTimeout(timeoutID1);
  }
  if (timeoutID2) {
    window.clearTimeout(timeoutID2);
  }
  var element = document.getElementById('msg');
  element.innerHTML = msg;
  element.className = 'error';
  timeoutID1 = window.setTimeout(function() {
    if (element.className !== 'error') {
      return;
    }
    element.className = 'error-hide';
    timeoutID2 = window.setTimeout(function() {
      element.innerHTML = '';
      element.className = '';
    }, 500);
  }, 10000);
}

/**
 * Prints the given informational message.
 * @param {string} msg - The information message to print.
 */
function info(msg) {
  var element = document.getElementById('msg');
  element.innerHTML = msg;
  element.className = 'info';
}

/**
 * Converts an address object into a dictionary.
 * @param {PaymentAddress} addr - The address to convert.
 * @return {object} The resulting dictionary.
 */
function toDictionary(addr) {  // eslint-disable-line no-unused-vars
  var dict = {};
  if (addr) {
    dict.country = addr.country;
    dict.region = addr.region;
    dict.city = addr.city;
    dict.dependentLocality = addr.dependentLocality;
    dict.addressLine = addr.addressLine;
    dict.postalCode = addr.postalCode;
    dict.sortingCode = addr.sortingCode;
    dict.languageCode = addr.languageCode;
    dict.organization = addr.organization;
    dict.recipient = addr.recipient;
    dict.careOf = addr.careOf;
    dict.phone = addr.phone;
  }
  return dict;
}

/**
 * Called when the payment request is complete.
 * @param {string} message - The human readable message to display.
 * @param {ShippingAddress} shippingAddress - User's shipping address.
 * @param {string} shippingOption - User's preferred shipping opion.
 * @param {string} methodName - The type of payment instrument the user is
 *                              providing.
 * @param {object} instrumentDetails - The payment instrument data to charge.
 * @param {object} totalAmount - The total amount to charge.
 * @param {string} payerEmail - User's preferred contact email address.
 * @param {string} payerPhone - User's preferred contact phone number.
 */
function done(message, shippingAddress, shippingOption, methodName, instrumentDetails, totalAmount, payerEmail, payerPhone) {  // eslint-disable-line no-unused-vars
  var element = document.getElementById('contents');
  element.innerHTML = message;
  info('total:<br/>' +
    JSON.stringify(totalAmount, undefined, 2) +
    '<br/>' +
    'method:<br/>' +
    methodName +
    '<br/>' +
    'instrument:<br/>' +
    JSON.stringify(instrumentDetails, undefined, 2) +
    '<br/>' +
    'shipping option:<br/>' +
    shippingOption +
    '<br/>' +
    'shipping address:<br/>' +
    JSON.stringify(toDictionary(shippingAddress), undefined, 2) +
    '<br/>' +
    'email:<br/>' +
    payerEmail +
    '<br/>' +
    'phone:<br/>' +
    payerPhone);
}<commit_msg>Put single line fields together<commit_after>var timeoutID1;
var timeoutID2;

/**
 * Prints the given error message.
 * @param {string} msg - The error message to print.
 */
function error(msg) {  // eslint-disable-line no-unused-vars
  if (timeoutID1) {
    window.clearTimeout(timeoutID1);
  }
  if (timeoutID2) {
    window.clearTimeout(timeoutID2);
  }
  var element = document.getElementById('msg');
  element.innerHTML = msg;
  element.className = 'error';
  timeoutID1 = window.setTimeout(function() {
    if (element.className !== 'error') {
      return;
    }
    element.className = 'error-hide';
    timeoutID2 = window.setTimeout(function() {
      element.innerHTML = '';
      element.className = '';
    }, 500);
  }, 10000);
}

/**
 * Prints the given informational message.
 * @param {string} msg - The information message to print.
 */
function info(msg) {
  var element = document.getElementById('msg');
  element.innerHTML = msg;
  element.className = 'info';
}

/**
 * Converts an address object into a dictionary.
 * @param {PaymentAddress} addr - The address to convert.
 * @return {object} The resulting dictionary.
 */
function toDictionary(addr) {  // eslint-disable-line no-unused-vars
  var dict = {};
  if (addr) {
    dict.country = addr.country;
    dict.region = addr.region;
    dict.city = addr.city;
    dict.dependentLocality = addr.dependentLocality;
    dict.addressLine = addr.addressLine;
    dict.postalCode = addr.postalCode;
    dict.sortingCode = addr.sortingCode;
    dict.languageCode = addr.languageCode;
    dict.organization = addr.organization;
    dict.recipient = addr.recipient;
    dict.careOf = addr.careOf;
    dict.phone = addr.phone;
  }
  return dict;
}

/**
 * Called when the payment request is complete.
 * @param {string} message - The human readable message to display.
 * @param {ShippingAddress} shippingAddress - User's shipping address.
 * @param {string} shippingOption - User's preferred shipping opion.
 * @param {string} methodName - The type of payment instrument the user is
 *                              providing.
 * @param {object} instrumentDetails - The payment instrument data to charge.
 * @param {object} totalAmount - The total amount to charge.
 * @param {string} payerEmail - User's preferred contact email address.
 * @param {string} payerPhone - User's preferred contact phone number.
 */
function done(message, shippingAddress, shippingOption, methodName, instrumentDetails, totalAmount, payerEmail, payerPhone) {  // eslint-disable-line no-unused-vars
  var element = document.getElementById('contents');
  element.innerHTML = message;
  info('method: ' + methodName +
    '<br/>' +
    'shipping option: ' + shippingOption +
    '<br/>' +
    '<br/>' +
    'email: ' + payerEmail +
    '<br/>' +
    'phone: ' + payerPhone +
    '<br/>' +
    'total:<br/>' +
    JSON.stringify(totalAmount, undefined, 2) +
    '<br/>' +
    'instrument:<br/>' +
    JSON.stringify(instrumentDetails, undefined, 2) +
    '<br/>' +
    'shipping address:<br/>' +
    JSON.stringify(toDictionary(shippingAddress), undefined, 2));
}
{'fraction_non_alphanumeric': 0.13462157809983896, 'fraction_numerical': 0.006119162640901771, 'mean_word_length': 3.307212205270458, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '1239203', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1865, 'n_words': 487}