<commit_before>$(document).ready(function() {
    $("form.search").submit(function() {
      var query = $('#query').val().split(',');
      showResults(query);
      return false;
    });
});

var getIp = function() {
  var promise = $.Deferred();
  $.ajax({
    url: "http://ipinfo.io",
    type: 'get',
    dataType: 'jsonp',
    success: function(result) {
      promise.resolve(result.ip);
    }
  });
  return promise;
}

var getParams = function() {
  var promise = $.Deferred();
  $.when(
    getIp()
  ).then(function(ip){
      var data = ({
        v : "1",
        format : "json",
        "t.p" : "51706",
        "t.k" : "xBpFKWDKEM",
        userip: ip,
        useragent: navigator.userAgent,
        action: "employers"
      });
      promise.resolve(data);
  });
  return promise;
}

var showResults = function (query) {
  var url, el, i, cur;
  url = "http://api.glassdoor.com/api/api.htm";
  $.when(
    getParams()
  ).then(function(data) {
    console.log(data);
  });
}<commit_msg>get companies from Glassdoor API<commit_after>$(document).ready(function() {
    $("form.search").submit(function() {
      var query = $('#query').val().split(',');
      showResults(query);
      return false;
    });
});

var getIp = function() {
  var promise = $.Deferred();
  $.ajax({
    url: "http://ipinfo.io",
    type: 'get',
    dataType: 'jsonp',
    success: function(result) {
      promise.resolve(result.ip);
    }
  });
  return promise;
}

var getParams = function() {
  var promise = $.Deferred();
  $.when(
    getIp()
  ).then(function(ip){
      var data = ({
        v : "1",
        format : "json",
        "t.p" : "51706",
        "t.k" : "xBpFKWDKEM",
        userip: ip,
        useragent: navigator.userAgent,
        action: "employers"
      });
      promise.resolve(data);
  });
  return promise;
}

var getCompanies = function(url, query, params) {
  var results = [], deferreds = [];
  var promise = $.Deferred();

  query.forEach(function(entry){
    params.q = entry;
    deferreds.push(
      $.ajax({
        url: url,
        type: "get",
        data: params,
        dataType: 'jsonp',
        success: function(JSON) {results.push(JSON.response.employers[0])},
        error: function(XMLHttpRequest, textStatus, errorThrown) { 
          alert("Status: " + textStatus);
        }        
      })
    );
  });
  
  $.when.apply($, deferreds).then(function() {
    promise.resolve(results);
  });

  return promise;
}

var showResults = function (query) {
  var url, el, i, cur;
  url = "http://api.glassdoor.com/api/api.htm";
  $.when(
    getParams()
  ).then(function(data) {
    $.when(
      getCompanies(url, query, data)
    ).then(function(companies) {
        console.log(companies);
    });
  });
}
{'fraction_non_alphanumeric': 0.18679724338048603, 'fraction_numerical': 0.004715270221254987, 'mean_word_length': 2.3675213675213675, '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': '1591690', 'n_tokens_mistral': 955, 'n_tokens_neox': 936, 'n_words': 185}