<commit_before>(function() {
  'use strict';

  angular.module('ether-spinner').controller('SpinnerCtrl', SpinnerCtrl);

  /*@ngInject*/
  function SpinnerCtrl($route, $scope, SweetAlert, ethereum) {
    var vm = this;
    vm.isConnected = ethereum.isConnected;
    vm.setContribution = setContribution;
    vm.onAccountChanged = onAccountChanged;
    vm.getBalance = getBalance;

    var emptyBarColour = '#dce6e9';
    var contractAddress = '0x79edE3A98b042863384dE25788504532362d52D6';
    var contract = null;

    var chart;
    var contributorsData;
    var emptyDataSlot = {
      value: 5.0,
      color: emptyBarColour,
      label: "Empty"
    };

    activate();

    ///////////////////

    function activate() {
      createChart();
      if(!ethereum.isConnected()) { return; }

      var abi = [{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"contributors","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"goal","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"contributions","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"newHost","type":"address"}],"name":"changeHost","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"setContribution","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"numWinners","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"numContributors","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"addToContribution","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"increment","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"removeFromContribution","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"recentWins","outputs":[{"name":"winner","type":"address"},{"name":"timestamp","type":"uint256"},{"name":"contribution","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"host","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[{"name":"_goalInFinney","type":"uint256"},{"name":"_incrementInFinney","type":"uint256"},{"name":"_recentWinsCount","type":"uint8"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"winner","type":"address"},{"indexed":false,"name":"timestamp","type":"uint256"},{"indexed":false,"name":"contribution","type":"uint256"}],"name":"Won","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contributor","type":"address"}],"name":"ChangedContribution","type":"event"}];
      var contractBlueprint = ethereum.web3.eth.contract(abi);
      contract = contractBlueprint.at(contractAddress);

      vm.goal = ethereum.web3.fromWei(contract.goal(), 'ether').toString();
      vm.sliderStep = ethereum.web3.fromWei(contract.increment(), 'ether').toString();
      vm.onSliderChanged = onSliderChanged;
      emptyDataSlot.value = vm.goal;

      vm.accounts = ethereum.web3.eth.accounts;
      vm.selectedAccount = ethereum.web3.eth.defaultAccount;
      if(!vm.selectedAccount) {
        vm.selectedAccount = ethereum.web3.eth.coinbase;
      }

      initializeContributorsData();
      updateContributions();
      vm.desiredContribution = vm.currentContribution;

      updateBalance();
      updateNewBalance();
      updateRecentResults();

      var onContributionChangedEvent = contract.ChangedContribution();
      onContributionChangedEvent.watch(onContributionChanged);

      var onWonEvent = contract.Won();
      onWonEvent.watch(onWon);
    }

    function setContribution() {
      var deltaContribution = vm.desiredContribution - vm.currentContribution;
      var changeInWei = ethereum.web3.toWei(deltaContribution, 'ether');
      console.log(changeInWei);
      if(deltaContribution > 0) {
        contract.addToContribution(null, { value: changeInWei, from: vm.selectedAccount, to: contractAddress }, onContributionSet);
      } else if(deltaContribution < 0){
        contract.removeFromContribution(-changeInWei, { from: vm.selectedAccount, to: contractAddress }, onContributionSet);
      }<commit_msg>Adjusted the site to use setContribution rather than add/removing.<commit_after>(function() {
  'use strict';

  angular.module('ether-spinner').controller('SpinnerCtrl', SpinnerCtrl);

  /*@ngInject*/
  function SpinnerCtrl($route, $scope, SweetAlert, ethereum) {
    var vm = this;
    vm.isConnected = ethereum.isConnected;
    vm.setContribution = setContribution;
    vm.onAccountChanged = onAccountChanged;
    vm.getBalance = getBalance;

    var emptyBarColour = '#dce6e9';
    var contractAddress = '0x79edE3A98b042863384dE25788504532362d52D6';
    var contract = null;

    var chart;
    var contributorsData;
    var emptyDataSlot = {
      value: 5.0,
      color: emptyBarColour,
      label: "Empty"
    };

    activate();

    ///////////////////

    function activate() {
      createChart();
      if(!ethereum.isConnected()) { return; }

      var abi = [{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"contributors","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"goal","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"contributions","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"newHost","type":"address"}],"name":"changeHost","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"setContribution","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"numWinners","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"numContributors","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"addToContribution","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"increment","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"removeFromContribution","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"recentWins","outputs":[{"name":"winner","type":"address"},{"name":"timestamp","type":"uint256"},{"name":"contribution","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"host","outputs":[{"name":"","type":"address"}],"type":"function"},{"inputs":[{"name":"_goalInFinney","type":"uint256"},{"name":"_incrementInFinney","type":"uint256"},{"name":"_recentWinsCount","type":"uint8"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"winner","type":"address"},{"indexed":false,"name":"timestamp","type":"uint256"},{"indexed":false,"name":"contribution","type":"uint256"}],"name":"Won","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contributor","type":"address"}],"name":"ChangedContribution","type":"event"}];
      var contractBlueprint = ethereum.web3.eth.contract(abi);
      contract = contractBlueprint.at(contractAddress);

      vm.goal = ethereum.web3.fromWei(contract.goal(), 'ether').toString();
      vm.sliderStep = ethereum.web3.fromWei(contract.increment(), 'ether').toString();
      vm.onSliderChanged = onSliderChanged;
      emptyDataSlot.value = vm.goal;

      vm.accounts = ethereum.web3.eth.accounts;
      vm.selectedAccount = ethereum.web3.eth.defaultAccount;
      if(!vm.selectedAccount) {
        vm.selectedAccount = ethereum.web3.eth.coinbase;
      }

      initializeContributorsData();
      updateContributions();
      vm.desiredContribution = vm.currentContribution;

      updateBalance();
      updateNewBalance();
      updateRecentResults();

      var onContributionChangedEvent = contract.ChangedContribution();
      onContributionChangedEvent.watch(onContributionChanged);

      var onWonEvent = contract.Won();
      onWonEvent.watch(onWon);
    }

    function setContribution() {
      var deltaContribution = vm.desiredContribution - vm.currentContribution;
      var desiredContributionInWei = ethereum.web3.toWei(vm.desiredContribution, 'ether');

      var valueToSend = 0;
      if(deltaContribution > 0) {
        valueToSend = ethereum.web3.toWei(deltaContribution, 'ether');
      }

      contract.setContribution(desiredContributionInWei, { value: valueToSend, from: vm.selectedAccount, to: contractAddress }, onContributionSet);
{'fraction_non_alphanumeric': 0.23735670937289277, 'fraction_numerical': 0.020566419420094403, 'mean_word_length': 7.119525547445256, 'pattern_counts': {'":': 250, '<': 4, '<?xml version=': 0, '>': 5, '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': '6026169', 'n_tokens_mistral': 2845, 'n_tokens_neox': 2614, 'n_words': 242}