<commit_before>/* This Source Code Form is subject to the terms of the MIT license
 * If a copy of the MIT license was not distributed with this file, you can
 * obtain one at http://www.mozillapopcorn.org/butter-license.txt */

define(['util/xhr'], function(XHR) {

  function audience() {
    return location.protocol + "//" + location.hostname + ( location.port ? ":" + location.port : "" );
  }

  function parameterize(data) {
    var s = [];

    for (var key in data) {
      s[s.length] = encodeURIComponent(key) + "=" + encodeURIComponent(data[key]);
    }

    return s.join("&").replace("/%20/g", "+");
  }

  var Cornfield = function( butter, config ) {

    var email = "",
        server = config.server;

    this.login = function(callback) {
      navigator.id.get(function(assertion) {
        if (assertion) {
          XHR.post(server + "/browserid/verify",
            { audience: audience(), assertion: assertion },
            function() {
              if (this.readyState === 4) {
                try {
                  var response = JSON.parse(this.response);
                  if (response.status === "okay") {
                    email = response.email;
                  }
                  callback(response);
                } catch (err) {
                  callback({ error: "an unknown error occured" });
                }
              }
            });
        } else {
          callback(undefined);
        }
      });
    };

    this.user = function() {
      return email;
    };

    this.logout = function(callback) {
      XHR.get(server + "/browserid/logout", function() {
        if (this.readyState === 4) {
          try {
            var response = JSON.parse(this.response);
            callback(response);
          } catch (err) {
            callback({ error: "an unknown error occured" });
          }
        }
      });
    }

    this.list = function(callback) {
      XHR.get(server + "/files", function() {
        if (this.readyState === 4) {
          try {
            var response = JSON.parse(this.response);
            callback(response);
          } catch (err) {
            callback({ error: "an unknown error occured" });
          }
        }
      });
    };

    // XXX I need to figure out a better API for this
    this.pull = function(name, callback) {
      XHR.get(server + "/files/" + name, function() {
        if (this.readyState === 4) {
          callback(this.response);
        }
      });
    };

    this.push = function(name, data, callback) {
      XHR.put(server + "/files/" + name, data, function() {
        if (this.readyState === 4) {
          try {
            var response = JSON.parse(this.response);
            callback(response);
          } catch (err) {
            callback({ error: "an unknown error occured" });
          }
        }
      });
    };
  };

  return Cornfield;
});
<commit_msg>Removed unused function<commit_after>/* This Source Code Form is subject to the terms of the MIT license
 * If a copy of the MIT license was not distributed with this file, you can
 * obtain one at http://www.mozillapopcorn.org/butter-license.txt */

define(['util/xhr'], function(XHR) {

  function audience() {
    return location.protocol + "//" + location.hostname + ( location.port ? ":" + location.port : "" );
  }

  var Cornfield = function( butter, config ) {

    var email = "",
        server = config.server;

    this.login = function(callback) {
      navigator.id.get(function(assertion) {
        if (assertion) {
          XHR.post(server + "/browserid/verify",
            { audience: audience(), assertion: assertion },
            function() {
              if (this.readyState === 4) {
                try {
                  var response = JSON.parse(this.response);
                  if (response.status === "okay") {
                    email = response.email;
                  }
                  callback(response);
                } catch (err) {
                  callback({ error: "an unknown error occured" });
                }
              }
            });
        } else {
          callback(undefined);
        }
      });
    };

    this.user = function() {
      return email;
    };

    this.logout = function(callback) {
      XHR.get(server + "/browserid/logout", function() {
        if (this.readyState === 4) {
          try {
            var response = JSON.parse(this.response);
            callback(response);
          } catch (err) {
            callback({ error: "an unknown error occured" });
          }
        }
      });
    }

    this.list = function(callback) {
      XHR.get(server + "/files", function() {
        if (this.readyState === 4) {
          try {
            var response = JSON.parse(this.response);
            callback(response);
          } catch (err) {
            callback({ error: "an unknown error occured" });
          }
        }
      });
    };

    // XXX I need to figure out a better API for this
    this.pull = function(name, callback) {
      XHR.get(server + "/files/" + name, function() {
        if (this.readyState === 4) {
          callback(this.response);
        }
      });
    };

    this.push = function(name, data, callback) {
      XHR.put(server + "/files/" + name, data, function() {
        if (this.readyState === 4) {
          try {
            var response = JSON.parse(this.response);
            callback(response);
          } catch (err) {
            callback({ error: "an unknown error occured" });
          }
        }
      });
    };
  };

  return Cornfield;
});

{'fraction_non_alphanumeric': 0.13933106778751564, 'fraction_numerical': 0.0021463065641209086, 'mean_word_length': 1.5985130111524164, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1506165', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1527, 'n_words': 378}