<commit_before>export default class Display {

  constructor(eventEmitter) {
    this.eventEmitter = eventEmitter;
    this.active = false;
    this.cursor = 0;
    this.root;
    this.tabs;

    this.eventEmitter.on('keyboard:next', () => {
      if (!this.active) {
        this.activate();
      } else {
        this.highlightNextTab();
      }
    });

    this.eventEmitter.on('keyboard:previous', () => {
      this.highlightPreviousTab();
    });

    this.eventEmitter.on('keyboard:select', () => {
      this.selectHighlightedTab();
      this.deactivate();
    });

    this.eventEmitter.on('keyboard:cancel', () => {
      this.deactivate();
    });

    chrome.runtime.connect().onDisconnect.addListener(() => { this.destroy(); });
  }

  activate() {
    this.getTabs(() => {
      this.render();
      this.highlightNextTab();
      this.active = true;
    });
  }

  deactivate() {
    document.body.removeChild(this.root);
    this.active = false;
    this.cursor = 0;
  }

  destroy() {
    if (this.active) {
      this.deactivate();
    }
    this.eventEmitter = undefined;
    this.active = undefined;
    this.cursor = undefined;
    this.root = undefined;
    this.tabs = undefined;
  }

  highlightTab(tab){
    this.tabs[this.cursor].tabCon.classList.remove('TAS_highlighted');
    this.cursor = tab.cursor;
    this.tabs[this.cursor].tabCon.classList.add('TAS_highlighted');
  }

  highlightNextTab() {
    this.tabs[this.cursor].tabCon.classList.remove('TAS_highlighted');
    if (this.cursor === this.tabs.length - 1) {
      this.cursor = -1;
    }
    this.tabs[++this.cursor].tabCon.classList.add('TAS_highlighted');
  }

  highlightPreviousTab() {
    this.tabs[this.cursor].tabCon.classList.remove('TAS_highlighted');
    if (this.cursor === 0) {
      this.cursor = this.tabs.length;
    }
    this.tabs[--this.cursor].tabCon.classList.add('TAS_highlighted');
  }

  selectHighlightedTab() {
    chrome.runtime.sendMessage({ selectTab: this.tabs[this.cursor] });
  }

  getTabs(cb) {
    chrome.runtime.sendMessage({ tabs: true }, (response) => {
      this.tabs = response.tabs;
      cb();
    });
  }

  render() {
    this.root = document.createElement('div');
    this.root.classList.add('TAS_root');
    var shadow = this.root.createShadowRoot();
    var displayCon = document.createElement('div');
    displayCon.classList.add('TAS_displayCon');
    document.body.appendChild(this.root);
    shadow.appendChild(displayCon);

    let l = this.tabs.length;
    for (let i = 0; i < l; i++) {
      let tab = this.tabs[i];

      let tabCon = document.createElement('div');
      let tabTitle = document.createElement('div');
      let tabTitleText = document.createElement('div');
      let tabIcon = document.createElement('div');

      tabTitle.setAttribute('title', tab.url);
      tabTitleText.appendChild(document.createTextNode(tab.title));
      if (tab.favIconUrl && tab.url != 'chrome://extensions/') {
        tabIcon.style.backgroundImage = 'url(\'' + tab.favIconUrl + '\')';
      }

      tabCon.classList.add('TAS_tabCon', 'mdl-card', 'mdl-shadow--2dp');
      tabTitle.classList.add('TAS_tabTitle', 'mdl-card__title');
      tabTitleText.classList.add('TAS_tabTitleText', 'mdl-typography--title');
      tabIcon.classList.add('TAS_tabIcon', 'mdl-list__item-icon', 'mdl-shadow--1dp');

      displayCon.appendChild(tabCon);
      tabCon.appendChild(tabIcon);
      tabCon.appendChild(tabTitle);
      tabTitle.appendChild(tabTitleText);
<commit_msg>check for problimatic favicon<commit_after>export default class Display {

  constructor(eventEmitter) {
    this.eventEmitter = eventEmitter;
    this.active = false;
    this.cursor = 0;
    this.root;
    this.tabs;

    this.eventEmitter.on('keyboard:next', () => {
      if (!this.active) {
        this.activate();
      } else {
        this.highlightNextTab();
      }
    });

    this.eventEmitter.on('keyboard:previous', () => {
      this.highlightPreviousTab();
    });

    this.eventEmitter.on('keyboard:select', () => {
      this.selectHighlightedTab();
      this.deactivate();
    });

    this.eventEmitter.on('keyboard:cancel', () => {
      this.deactivate();
    });

    chrome.runtime.connect().onDisconnect.addListener(() => { this.destroy(); });
  }

  activate() {
    this.getTabs(() => {
      this.render();
      this.highlightNextTab();
      this.active = true;
    });
  }

  deactivate() {
    document.body.removeChild(this.root);
    this.active = false;
    this.cursor = 0;
  }

  destroy() {
    if (this.active) {
      this.deactivate();
    }
    this.eventEmitter = undefined;
    this.active = undefined;
    this.cursor = undefined;
    this.root = undefined;
    this.tabs = undefined;
  }

  highlightTab(tab) {
    this.tabs[this.cursor].tabCon.classList.remove('TAS_highlighted');
    this.cursor = tab.cursor;
    this.tabs[this.cursor].tabCon.classList.add('TAS_highlighted');
  }

  highlightNextTab() {
    this.tabs[this.cursor].tabCon.classList.remove('TAS_highlighted');
    if (this.cursor === this.tabs.length - 1) {
      this.cursor = -1;
    }
    this.tabs[++this.cursor].tabCon.classList.add('TAS_highlighted');
  }

  highlightPreviousTab() {
    this.tabs[this.cursor].tabCon.classList.remove('TAS_highlighted');
    if (this.cursor === 0) {
      this.cursor = this.tabs.length;
    }
    this.tabs[--this.cursor].tabCon.classList.add('TAS_highlighted');
  }

  selectHighlightedTab() {
    chrome.runtime.sendMessage({ selectTab: this.tabs[this.cursor] });
  }

  getTabs(cb) {
    chrome.runtime.sendMessage({ tabs: true }, (response) => {
      this.tabs = response.tabs;
      cb();
    });
  }

  render() {
    this.root = document.createElement('div');
    this.root.classList.add('TAS_root');
    var shadow = this.root.createShadowRoot();
    var displayCon = document.createElement('div');
    displayCon.classList.add('TAS_displayCon');
    document.body.appendChild(this.root);
    shadow.appendChild(displayCon);

    let l = this.tabs.length;
    for (let i = 0; i < l; i++) {
      let tab = this.tabs[i];

      let tabCon = document.createElement('div');
      let tabTitle = document.createElement('div');
      let tabTitleText = document.createElement('div');
      let tabIcon = document.createElement('div');

      tabTitle.setAttribute('title', tab.url);
      tabTitleText.appendChild(document.createTextNode(tab.title));
      if (tab.favIconUrl.indexOf('chrome://theme/') !== 0) {
        tabIcon.style.backgroundImage = 'url(\'' + tab.favIconUrl + '\')';
      }

      tabCon.classList.add('TAS_tabCon', 'mdl-card', 'mdl-shadow--2dp');
      tabTitle.classList.add('TAS_tabTitle', 'mdl-card__title');
      tabTitleText.classList.add('TAS_tabTitleText', 'mdl-typography--title');
      tabIcon.classList.add('TAS_tabIcon', 'mdl-list__item-icon', 'mdl-shadow--1dp');

      displayCon.appendChild(tabCon);
      tabCon.appendChild(tabIcon);
      tabCon.appendChild(tabTitle);
      tabTitle.appendChild(tabTitleText);

{'fraction_non_alphanumeric': 0.16602536696593986, 'fraction_numerical': 0.0024226877583012683, 'mean_word_length': 3.0356526739505463, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '632756', 'n_tokens_mistral': 2300, 'n_tokens_neox': 2255, 'n_words': 302}