<commit_before>import { Events } from 'groupby-api';
import { unless, getParam } from '../../utils';
import { mount } from '../sayt/query-wrapper';

const ENTER_KEY = 13;

export class Query {

  opts: any;
  root: HTMLInputElement;
  on: (string, Function) => void;

  queryParam: string;
  searchUrl: string;
  staticSearch: string;

  init() {
    const saytEnabled = unless(this.opts.sayt, true);
    const autoSearch = unless(this.opts.autoSearch, true);
    const queryFromUrl = getParam(this.queryParam);
    const inputValue = () => this.root.value;

    this.queryParam = this.opts.queryParam || 'q';
    this.searchUrl = `${this.opts.searchUrl || 'search'}?${this.queryParam}=`;
    this.staticSearch = unless(this.opts.staticSearch, false);

    if (saytEnabled) mount(<Riot.Tag.Instance & any>this);
    if (autoSearch) {
      this.on('before-mount', () => this.listenForInput(inputValue));
    } else if (this.staticSearch) {
      this.on('before-mount', () => this.listenForStaticSubmit(inputValue));<commit_msg>Fix query string search<commit_after>import { Events } from 'groupby-api';
import { unless, getParam } from '../../utils';
import { mount } from '../sayt/query-wrapper';

const ENTER_KEY = 13;

export class Query {

  opts: any;
  root: HTMLInputElement;
  on: (string, Function) => void;

  queryParam: string;
  searchUrl: string;
  staticSearch: string;

  init() {
    const saytEnabled = unless(this.opts.sayt, true);
    const autoSearch = unless(this.opts.autoSearch, true);
    const inputValue = () => this.root.value;

    this.queryParam = this.opts.queryParam || 'q';
    this.searchUrl = `${this.opts.searchUrl || 'search'}?${this.queryParam}=`;
    this.staticSearch = unless(this.opts.staticSearch, false);

    const queryFromUrl = getParam(this.queryParam);

    if (saytEnabled) mount(<Riot.Tag.Instance & any>this);
    if (autoSearch) {
      this.on('before-mount', () => this.listenForInput(inputValue));
    } else if (this.staticSearch) {
      this.on('before-mount', () => this.listenForStaticSubmit(inputValue));
{'fraction_non_alphanumeric': 0.1606192549588776, 'fraction_numerical': 0.0019351717464925011, 'mean_word_length': 3.888888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4302727', 'n_tokens_mistral': 667, 'n_tokens_neox': 653, 'n_words': 142}