<commit_before>function logError(fn) {
  return function (text) {
    try {
      fn(text);
    } catch (ex) {
      if (typeof console !== "undefined" && typeof console.error !== "undefined") {
        console.error('exception caught evaling RJS');
        console.error(ex);
        console.debug('script follows:', text);
      }
    }
    return text;
  };
}

jQuery.jsonPayload = function (text, fallback) {
  var parsed_json = jQuery.parseJSON(text);
  if (parsed_json.explorer) {
    return ManageIQ.explorer.process(parsed_json); // ExplorerPresenter payload
  } else {
    return fallback(text);
  }
};

$.ajaxSetup({
  accepts: {
    json: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript",
  },
  contents: {
    json: /application\/json/,
  },
  converters: {
    "text json": logError(function (text) {
      return jQuery.jsonPayload(text, function (text) {
        return jQuery.parseJSON(text);
      });
    }),
    "text script": logError(function (text) {<commit_msg>jquery_overrides - return the functions' output in logError when successful<commit_after>function logError(fn) {
  return function (text) {
    try {
      return fn(text);
    } catch (ex) {
      if (typeof console !== "undefined" && typeof console.error !== "undefined") {
        console.error('exception caught evaling RJS');
        console.error(ex);
        console.debug('script follows:', text);
      }
      return text;
    }
  };
}

jQuery.jsonPayload = function (text, fallback) {
  var parsed_json = jQuery.parseJSON(text);
  if (parsed_json.explorer) {
    return ManageIQ.explorer.process(parsed_json); // ExplorerPresenter payload
  } else {
    return fallback(text);
  }
};

$.ajaxSetup({
  accepts: {
    json: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript",
  },
  contents: {
    json: /application\/json/,
  },
  converters: {
    "text json": logError(function (text) {
      return jQuery.jsonPayload(text, function (text) {
        return jQuery.parseJSON(text);
      });
    }),
    "text script": logError(function (text) {
{'fraction_non_alphanumeric': 0.14104372355430184, 'fraction_numerical': 0.0, 'mean_word_length': 3.124031007751938, 'pattern_counts': {'":': 4, '<': 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': '3942279', 'n_tokens_mistral': 646, 'n_tokens_neox': 650, 'n_words': 143}