<commit_before>(function() {
  var root = window;

  // Default settings
  var config = {
    api_url: "https://api.printfection.com/v2",
    api_token: null,
    popup_settings: 'height=850,width=1000,left=100,top=100,scrollbars=yes,toolbar=no,status=no'
  };

  var PF = {};
  root.Printfection = PF;

  PF.configure = function(settings) {
    for (var key in settings) {
      config[key] = settings[key];
    }
  };



  //
  // API Service
  //
  var API = {
    request: function(type, endpoint, callback) {
      callback    = callback || function(){};
      var url     = config.api_url + endpoint;
      var auth    = btoa(config.api_token + ":");
      var request = new XMLHttpRequest();
      request.open(type.toUpperCase(), url, true);
      request.setRequestHeader("Authorization","Basic " + auth);
      request.setRequestHeader("Content-type", "application/json");
      request.onreadystatechange = function () {;
        if (request.readyState == 4 && request.status == 200) {
          var response = JSON.parse(request.responseText);
          if (response.object == "list" && response.data) {
            callback(response.data);
          } else {
            callback(response);
          }
        }
      }
      return request;
    },

    get: function(endpoint, callback) {
      API.request("GET", endpoint, callback).send();
    },

    post: function(endpoint, payload, callback) {
      API.request("POST", endpoint, callback).send(JSON.stringify(payload));
    }
  };


  //
  // API Module
  //
  var UI = {
    init: function() {
      var buttons = document.getElementsByClassName('pf-order-button');
      for (i = 0; i < buttons.length; i += 1) {
        UI.bindButton(buttons[i]);
      }
    },

    bindButton: function(button) {
      button.addEventListener("click", function(event) {
        event.preventDefault();
        var campaign_id = button.dataset.campaignId;
        var ship_to = {
          name:      button.dataset.name,
          company:   button.dataset.company,
          address:   button.dataset.address,
          address_2: button.dataset.address_2,
          city:      button.dataset.city,
          state:     button.dataset.state,
          zip:       button.dataset.zip,
          country:   button.dataset.country,
          email:     button.dataset.email,
          phone:     button.dataset.phone
        };
        UI.createAndOpenOrder(campaign_id, ship_to);
      });
    },

    createAndOpenOrder: function(campaign_id, ship_to) {
      Printfection.Orders.create({
        campaign_id: campaign_id,
      }, function(order) {
        order.open(ship_to);
      });
    }
  };


  //
  // Campaigns Service
  //
  PF.Campaigns = {
    retrieve: function(id, callback) {
      callback = callback || function(){};
      API.get("/campaigns/" + id, function(response) {;
        var order = new Campaign(response);
        callback(order);
      });
    }
  };


  //
  // Campaign Class
  //
  var Campaign = function(properties) {
    for (var key in properties) {
      this[key] = properties[key];
    }
  };


  //
  // Orders Service
  //
  PF.Orders = {
    all: function(callback) {
      callback = callback || function(){};
      API.get("/orders", function(response) {
        var orders = [];
        for (i = 0; i < response.length; i += 1) {
          orders.push(new Order(response[i]));
        }
        callback(orders);
      });
    },
    retrieve: function(id, callback) {
      callback = callback || function(){};
      API.get("/orders/" + id, function(response) {
        var order = new Order(response);
        callback(order);
      });
    },
    create: function(properties, callback) {
      callback = callback || function(){};
      API.post("/orders", properties, function(response) {
        var order = new Order(response);
        callback(order);
      });
    }
  };


  //
  // Order Class
  //
  var Order = function(properties) {
    for (var key in properties) {
      this[key] = properties[key];
    }
  };

  Order.prototype.open = function(options, callback) {
    options = options || {};
    callback = callback || function(){};

    var queries = [];
    options['name']       ? queries.push('name='      + options['name']) : '';
    options['company']    ? queries.push('company='   + options['company']) : '';
    options['address']    ? queries.push('address='   + options['address']) : '';
    options['address_2']  ? queries.push('address_2=' + options['address_2']) : '';
    options['city']       ? queries.push('city='      + options['city']) : '';
    options['state']      ? queries.push('state='     + options['state']) : '';
    options['zip']        ? queries.push('zip='       + options['zip']) : '';
    options['country']    ? queries.push('country='   + options['country']) : '';
    options['email']      ? queries.push('email='     + options['email']) : '';
    options['phone']      ? queries.push('phone='     + options['phone']) : '';
    var url = this.url + "?" + queries.join("&");
    
    var child_window = window.open(url, "_blank", config.popup_settings);    
    var timer = setInterval(function(){
	    if(child_window.closed){
			  clearInterval(timer); 
		  	callback();
	  	}
  	}, 500);
  };

  //
  // Initialize
  //
  root.addEventListener('load', function() {
    UI.init();
  });
})();
<commit_msg>Whitespace<commit_after>(function() {
  var root = window;

  // Default settings
  var config = {
    api_url: "https://api.printfection.com/v2",
    api_token: null,
    popup_settings: 'height=850,width=1000,left=100,top=100,scrollbars=yes,toolbar=no,status=no'
  };

  var PF = {};
  root.Printfection = PF;

  PF.configure = function(settings) {
    for (var key in settings) {
      config[key] = settings[key];
    }
  };


  //
  // API Service
  //
  var API = {
    request: function(type, endpoint, callback) {
      callback    = callback || function(){};
      var url     = config.api_url + endpoint;
      var auth    = btoa(config.api_token + ":");
      var request = new XMLHttpRequest();
      request.open(type.toUpperCase(), url, true);
      request.setRequestHeader("Authorization","Basic " + auth);
      request.setRequestHeader("Content-type", "application/json");
      request.onreadystatechange = function () {;
        if (request.readyState == 4 && request.status == 200) {
          var response = JSON.parse(request.responseText);
          if (response.object == "list" && response.data) {
            callback(response.data);
          } else {
            callback(response);
          }
        }
      }
      return request;
    },

    get: function(endpoint, callback) {
      API.request("GET", endpoint, callback).send();
    },

    post: function(endpoint, payload, callback) {
      API.request("POST", endpoint, callback).send(JSON.stringify(payload));
    }
  };


  //
  // API Module
  //
  var UI = {
    init: function() {
      var buttons = document.getElementsByClassName('pf-order-button');
      for (i = 0; i < buttons.length; i += 1) {
        UI.bindButton(buttons[i]);
      }
    },

    bindButton: function(button) {
      button.addEventListener("click", function(event) {
        event.preventDefault();
        var campaign_id = button.dataset.campaignId;
        var ship_to = {
          name:      button.dataset.name,
          company:   button.dataset.company,
          address:   button.dataset.address,
          address_2: button.dataset.address_2,
          city:      button.dataset.city,
          state:     button.dataset.state,
          zip:       button.dataset.zip,
          country:   button.dataset.country,
          email:     button.dataset.email,
          phone:     button.dataset.phone
        };
        UI.createAndOpenOrder(campaign_id, ship_to);
      });
    },

    createAndOpenOrder: function(campaign_id, ship_to) {
      Printfection.Orders.create({
        campaign_id: campaign_id,
      }, function(order) {
        order.open(ship_to);
      });
    }
  };


  //
  // Campaigns Service
  //
  PF.Campaigns = {
    retrieve: function(id, callback) {
      callback = callback || function(){};
      API.get("/campaigns/" + id, function(response) {;
        var order = new Campaign(response);
        callback(order);
      });
    }
  };


  //
  // Campaign Class
  //
  var Campaign = function(properties) {
    for (var key in properties) {
      this[key] = properties[key];
    }
  };


  //
  // Orders Service
  //
  PF.Orders = {
    all: function(callback) {
      callback = callback || function(){};
      API.get("/orders", function(response) {
        var orders = [];
        for (i = 0; i < response.length; i += 1) {
          orders.push(new Order(response[i]));
        }
        callback(orders);
      });
    },
    retrieve: function(id, callback) {
      callback = callback || function(){};
      API.get("/orders/" + id, function(response) {
        var order = new Order(response);
        callback(order);
      });
    },
    create: function(properties, callback) {
      callback = callback || function(){};
      API.post("/orders", properties, function(response) {
        var order = new Order(response);
        callback(order);
      });
    }
  };


  //
  // Order Class
  //
  var Order = function(properties) {
    for (var key in properties) {
      this[key] = properties[key];
    }
  };

  Order.prototype.open = function(options, callback) {
    options = options || {};
    callback = callback || function(){};

    var queries = [];
    options['name']       ? queries.push('name='      + options['name'])      : '';
    options['company']    ? queries.push('company='   + options['company'])   : '';
    options['address']    ? queries.push('address='   + options['address'])   : '';
    options['address_2']  ? queries.push('address_2=' + options['address_2']) : '';
    options['city']       ? queries.push('city='      + options['city'])      : '';
    options['state']      ? queries.push('state='     + options['state'])     : '';
    options['zip']        ? queries.push('zip='       + options['zip'])       : '';
    options['country']    ? queries.push('country='   + options['country'])   : '';
    options['email']      ? queries.push('email='     + options['email'])     : '';
    options['phone']      ? queries.push('phone='     + options['phone'])     : '';
    var url = this.url + "?" + queries.join("&");

    var child_window = window.open(url, "_blank", config.popup_settings);
    var timer = setInterval(function(){
      if (child_window.closed) {
        clearInterval(timer);
        callback();
      }
    }, 500);
  };

  //
  // Initialize
  //
  root.addEventListener('load', function() {
    UI.init();
  });
})();

{'fraction_non_alphanumeric': 0.16448528729230483, 'fraction_numerical': 0.00556947925368978, 'mean_word_length': 2.250075414781297, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2706156', 'n_tokens_mistral': 3245, 'n_tokens_neox': 3135, 'n_words': 593}