<commit_before>import $ from 'jquery';
import * as d3 from 'd3';
import { TweenLite } from 'gsap';
import numeral from 'numeral';
import noUiSlider from 'no-ui-slider';
import moment from 'moment';

class USTerritoriesStats {
  constructor() {
    this.dataUrl = 'http://media.miamiherald.com/static/media/projects/2016/zika-interactive-v2/data/usZika.json'
    this.totals = [
      '.territories__stat--local-as',
      '.territories__stat--travel-as',
      '.territories__stat--total-as',
      '.territories__stat--local-pr',
      '.territories__stat--travel-pr',
      '.territories__stat--total-pr',
      '.territories__stat--local-usvi',
      '.territories__stat--travel-usvi',
      '.territories__stat--total-usvi',
      '.territories__stat--local-totals',
      '.territories__stat--travel-totals',
      '.territories__stat--total-totals'
    ];
  }

  render() {
    this.loadData();
  }

  loadData() {
    d3.queue()
      .defer(d3.json, this.dataUrl)
      .await(this.loadStats.bind(this));
  }

  loadStats(error, caseData) {
    if (error) throw error;

    this.caseData = caseData;
    this.drawSlider();
    this.totals.forEach(i => {
      this.setTotals(i);
    });
    this.stepSlider.noUiSlider.on('update', () => {
      this.totals.forEach(i => {
        this.setTotals(i);
        this.setDate();
      });
    });
    this.switchTabs();
  }

  setTotals(el) {
    this.dataColumn = $('.tabs__link--us-territories-100k.is-active').data('number');

    if (this.dataColumn === 'total') {
      var counterStart = {var: $(el).text()};
      if (el === '.territories__stat--local-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].local};
      } else if (el === '.territories__stat--travel-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].travel};
      } else if (el === '.territories__stat--total-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].total};
      } else if (el === '.territories__stat--local-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].local};
      } else if (el === '.territories__stat--travel-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].travel};
      } else if (el === '.territories__stat--total-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].total};
      } else if (el === '.territories__stat--local-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].local};
      } else if (el === '.territories__stat--travel-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].travel};
      } else if (el === '.territories__stat--total-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].total};
      } else if (el === '.territories__stat--local-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territoryTotalLocal};
      } else if (el === '.territories__stat--travel-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territoryTotalTravel};
      } else if (el === '.territories__stat--total-totals') {
        var counterEnd = {var: +this.caseData[this.unformatSlider()].territoryTotalLocal + +this.caseData[this.unformatSlider()].territoryTotalTravel};
      }
    } else if (this.dataColumn === 'per100k') {
      var counterStart = {var: $(el).text()};
      if (el === '.territories__stat--local-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].per100KLocal};
      } else if (el === '.territories__stat--travel-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].per100KTravel};
      } else if (el === '.territories__stat--total-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].per100KTotal};
      } else if (el === '.territories__stat--local-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].per100KLocal};
      } else if (el === '.territories__stat--travel-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].per100KTravel};
      } else if (el === '.territories__stat--total-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].per100KTotal};
      } else if (el === '.territories__stat--local-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].per100KLocal};
      } else if (el === '.territories__stat--travel-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].per100KTravel};
      } else if (el === '.territories__stat--total-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].per100KTotal};
      } else if (el === '.territories__stat--local-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].perMillionTerritoryTotalLocal};
      } else if (el === '.territories__stat--travel-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].perMillionTerritoryTotalTravel};
      } else if (el === '.territories__stat--total-totals') {
        var counterEnd = {var: +this.caseData[this.unformatSlider()].perMillionTerritoryTotalLocal + +this.caseData[this.unformatSlider()].perMillionTerritoryTotalTravel};
      }
    }

    TweenMax.to(counterStart, 0.3, {var: counterEnd.var, onUpdate: () => {
        $(el).html(Math.ceil(counterStart.var));
      },
      ease:Circ.easeOut
    });
  }

  drawSlider() {<commit_msg>Updated territories totals<commit_after>import $ from 'jquery';
import * as d3 from 'd3';
import { TweenLite } from 'gsap';
import numeral from 'numeral';
import noUiSlider from 'no-ui-slider';
import moment from 'moment';

class USTerritoriesStats {
  constructor() {
    this.dataUrl = 'http://media.miamiherald.com/static/media/projects/2016/zika-interactive-v2/data/usZika.json'
    this.totals = [
      '.territories__stat--local-as',
      '.territories__stat--travel-as',
      '.territories__stat--total-as',
      '.territories__stat--local-pr',
      '.territories__stat--travel-pr',
      '.territories__stat--total-pr',
      '.territories__stat--local-usvi',
      '.territories__stat--travel-usvi',
      '.territories__stat--total-usvi',
      '.territories__stat--local-totals',
      '.territories__stat--travel-totals',
      '.territories__stat--total-totals'
    ];
  }

  render() {
    this.loadData();
  }

  loadData() {
    d3.queue()
      .defer(d3.json, this.dataUrl)
      .await(this.loadStats.bind(this));
  }

  loadStats(error, caseData) {
    if (error) throw error;

    this.caseData = caseData;
    this.drawSlider();
    this.totals.forEach(i => {
      this.setTotals(i);
    });
    this.stepSlider.noUiSlider.on('update', () => {
      this.totals.forEach(i => {
        this.setTotals(i);
        this.setDate();
      });
    });
    this.switchTabs();
  }

  setTotals(el) {
    this.dataColumn = $('.tabs__link--us-territories-100k.is-active').data('number');

    if (this.dataColumn === 'total') {
      var counterStart = {var: $(el).text()};
      if (el === '.territories__stat--local-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].local};
      } else if (el === '.territories__stat--travel-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].travel};
      } else if (el === '.territories__stat--total-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].total};
      } else if (el === '.territories__stat--local-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].local};
      } else if (el === '.territories__stat--travel-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].travel};
      } else if (el === '.territories__stat--total-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].total};
      } else if (el === '.territories__stat--local-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].local};
      } else if (el === '.territories__stat--travel-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].travel};
      } else if (el === '.territories__stat--total-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].total};
      } else if (el === '.territories__stat--local-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territoryTotalLocal};
      } else if (el === '.territories__stat--travel-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territoryTotalTravel};
      } else if (el === '.territories__stat--total-totals') {
        var counterEnd = {var: +this.caseData[this.unformatSlider()].territoryTotalLocal + +this.caseData[this.unformatSlider()].territoryTotalTravel};
      }
    } else if (this.dataColumn === 'per100k') {
      var counterStart = {var: $(el).text()};
      if (el === '.territories__stat--local-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].per100KLocal};
      } else if (el === '.territories__stat--travel-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].per100KTravel};
      } else if (el === '.territories__stat--total-as') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['American Samoa'].per100KTotal};
      } else if (el === '.territories__stat--local-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].per100KLocal};
      } else if (el === '.territories__stat--travel-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].per100KTravel};
      } else if (el === '.territories__stat--total-pr') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['Puerto Rico'].per100KTotal};
      } else if (el === '.territories__stat--local-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].per100KLocal};
      } else if (el === '.territories__stat--travel-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].per100KTravel};
      } else if (el === '.territories__stat--total-usvi') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].territories['United States Virgin Islands'].per100KTotal};
      } else if (el === '.territories__stat--local-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].per100KTerritoryTotalLocal};
      } else if (el === '.territories__stat--travel-totals') {
        var counterEnd = {var: this.caseData[this.unformatSlider()].per100KTerritoryTotalTravel};
      } else if (el === '.territories__stat--total-totals') {
        var counterEnd = {var: +this.caseData[this.unformatSlider()].per100KTerritoryTotalLocal + +this.caseData[this.unformatSlider()].per100KTerritoryTotalTravel};
      }
    }

    TweenMax.to(counterStart, 0.3, {var: counterEnd.var, onUpdate: () => {
        $(el).html(Math.ceil(counterStart.var));
      },
      ease:Circ.easeOut
    });
  }

  drawSlider() {
{'fraction_non_alphanumeric': 0.17246221194350375, 'fraction_numerical': 0.008259684480052862, 'mean_word_length': 3.449834619625138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4507605', 'n_tokens_mistral': 4057, 'n_tokens_neox': 3959, 'n_words': 628}