<commit_before>import utils from './utils';

import GeoMap from './components/GeoMap';
import Filters from './components/Filters';
import Table from './components/Table';

export default class MapTable {
  constructor(target, options) {
    this.options = options;

    this.state = {
      filters: {},
      zoom: {},
    };
    this.saveStateTimeout = {};

    this.node = document.querySelector(target);
    this.node.setAttribute('style', 'position:relative;');

    if (this.options.data.type === 'json') {
      d3.json(this.options.data.path, this.loadData.bind(this));
    } else if (this.options.data.type === 'csv') {
      d3.csv(this.options.data.path, this.loadData.bind(this));
    } else if (this.options.data.type === 'tsv') {
      d3.tsv(this.options.data.path, this.loadData.bind(this));
    }

    if (this.options.map && this.options.map.heatmap) {
      delete this.options.map.countries;
    }
  }

  /**
   * Callback used when we pull the dataset
   * @param err: Error - error data if it happened
   * @param data: Object - dataset object
   */
  loadData(err, data) {
    if (err) {
      throw err;
    }
    this.rawData = data;

    if (this.options.data.preFilter) {
      this.rawData = this.rawData.filter(this.options.data.preFilter);
    }

    this.setColumnDetails();
    this.data = this.rawData.slice(); // we clone data, so that we can filter it
    // Map
    if (this.options.map) {
      // Map wrapper
      const mapWrapper = document.createElement('div');
      mapWrapper.setAttribute('class', 'mt-map-container');
      mapWrapper.innerHTML = '<div class="mt-loading">Loading...</div>';
      this.node.insertBefore(mapWrapper, this.node.firstChild);<commit_msg>disable heatmap support for ie11<commit_after>import utils from './utils';

import GeoMap from './components/GeoMap';
import Filters from './components/Filters';
import Table from './components/Table';

export default class MapTable {
  constructor(target, options) {
    this.options = options;

    this.state = {
      filters: {},
      zoom: {},
    };
    this.saveStateTimeout = {};

    this.node = document.querySelector(target);
    this.node.setAttribute('style', 'position:relative;');

    if (this.options.data.type === 'json') {
      d3.json(this.options.data.path, this.loadData.bind(this));
    } else if (this.options.data.type === 'csv') {
      d3.csv(this.options.data.path, this.loadData.bind(this));
    } else if (this.options.data.type === 'tsv') {
      d3.tsv(this.options.data.path, this.loadData.bind(this));
    }

    if (this.options.map && this.options.map.heatmap) {
      delete this.options.map.countries;
    }
  }

  /**
   * Callback used when we pull the dataset
   * @param err: Error - error data if it happened
   * @param data: Object - dataset object
   */
  loadData(err, data) {
    if (err) {
      throw err;
    }
    this.rawData = data;

    if (this.options.data.preFilter) {
      this.rawData = this.rawData.filter(this.options.data.preFilter);
    }

    this.setColumnDetails();
    this.data = this.rawData.slice(); // we clone data, so that we can filter it
    // Map
    if (this.options.map) {
      // Map wrapper
      const mapWrapper = document.createElement('div');
      mapWrapper.setAttribute('class', 'mt-map-container');
      const isIE = (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0);
      if (this.options.map.heatmap && isIE) {
        mapWrapper.innerHTML = '<div class="mt-loading">The heatmap feature is not supported with Internet Explorer.<br>Please use another modern browser to see this map.</div>';
        this.node.insertBefore(mapWrapper, this.node.firstChild);
        mapWrapper.querySelector('.mt-loading').style.display = 'block';
        this.options.map = false;
        this.buildComponenents();
        return;
      }
      mapWrapper.innerHTML = '<div class="mt-loading">Loading...</div>';
      this.node.insertBefore(mapWrapper, this.node.firstChild);
{'fraction_non_alphanumeric': 0.15336658354114713, 'fraction_numerical': 0.0024937655860349127, 'mean_word_length': 2.913170731707317, 'pattern_counts': {'":': 0, '<': 10, '<?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': '2920373', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1234, 'n_words': 265}