<commit_before>import "@webcomponents/custom-elements";

import LoopElement from "./LoopElement.js";
import SoundMatrix from "../audio/SoundMatrix.js";

(function() {
  let style = document.createElement("style");
  style.textContent = `
    dlib-soundmatrix *:focus {
      outline: none;
    }
  `;
  document.head.appendChild(style);
})();

export default class SoundMatrixElement extends LoopElement {
  constructor({soundMatrix = new SoundMatrix()} = {}) {
    super();

    this.soundMatrix = soundMatrix;

    this._padsMatrix = new Map();
  }

  set soundMatrix(value) {
    if(this._soundMatrix) {
      this._soundMatrix.onBeat.delete(this._onBeatBinded);
    }
    this._soundMatrix = value;
    this._soundMatrix.onBeat.add(this._onBeatBinded = this._onBeat.bind(this));
  }

  get soundMatrix() {
    return this._soundMatrix;
  }

  _onBeat(beat) {
    for (let pads of this._padsMatrix.values()) {
      for (let [i, pad] of pads.entries()) {
        if(i !== beat && pad.classList.contains("highlight")) {
          pad.classList.remove("highlight");
        } else if(i === beat && !pad.classList.contains("highlight")) {
          pad.classList.add("highlight");
        }
      }
    }
  }

  update() {
    super.update();

    for (let [sound, array] of this.soundMatrix) {
      let pads = this._padsMatrix.get(sound);

      if(!pads) {
        let row = document.createElement("div");
        row.classList.add("row");

        let empty = document.createElement("input")
        empty.type = "button";
        empty.value = "✖";
        empty.onclick = () => {
          for (let i = 0; i < array.length; i++) {
            array[i] = 0;
          }
        }
        // row.appendChild(empty);
<commit_msg>add back empty button in SoundMatrixElement<commit_after>import "@webcomponents/custom-elements";

import LoopElement from "./LoopElement.js";
import SoundMatrix from "../audio/SoundMatrix.js";

(function() {
  let style = document.createElement("style");
  style.textContent = `
    dlib-soundmatrix *:focus {
      outline: none;
    }
  `;
  document.head.appendChild(style);
})();

export default class SoundMatrixElement extends LoopElement {
  constructor({soundMatrix = new SoundMatrix()} = {}) {
    super();

    this.soundMatrix = soundMatrix;

    this._padsMatrix = new Map();
  }

  set soundMatrix(value) {
    if(this._soundMatrix) {
      this._soundMatrix.onBeat.delete(this._onBeatBinded);
    }
    this._soundMatrix = value;
    this._soundMatrix.onBeat.add(this._onBeatBinded = this._onBeat.bind(this));
  }

  get soundMatrix() {
    return this._soundMatrix;
  }

  _onBeat(beat) {
    for (let pads of this._padsMatrix.values()) {
      for (let [i, pad] of pads.entries()) {
        if(i !== beat && pad.classList.contains("highlight")) {
          pad.classList.remove("highlight");
        } else if(i === beat && !pad.classList.contains("highlight")) {
          pad.classList.add("highlight");
        }
      }
    }
  }

  update() {
    super.update();

    for (let [sound, array] of this.soundMatrix) {
      let pads = this._padsMatrix.get(sound);

      if(!pads) {
        let row = document.createElement("div");
        row.classList.add("row");

        let empty = document.createElement("input")
        empty.type = "button";
        empty.value = "✖";
        empty.onclick = () => {
          for (let i = 0; i < array.length; i++) {
            array[i] = 0;
          }
        }
        row.appendChild(empty);

{'fraction_non_alphanumeric': 0.15296476654253796, 'fraction_numerical': 0.0011458034947006588, 'mean_word_length': 2.5889003083247686, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5432854', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1068, 'n_words': 209}