<commit_before>import utils from './util.js';
var TED_URL_REGEX = /^https?:\/\/www.ted.com\/talks\/(\w+)/;

export function searchPageHandler($http, params) {
  var match = TED_URL_REGEX.exec(decodeURIComponent(params.q));
  if (match) {
    document.location = '/talks/' + match[1];
  }
  var $input = document.querySelector('#search input[name=q]');
  $input.value = params.q;
  $input.focus();

  $http.get(`/api/search?q=${params.q}`).then((data) => {
    document.title = params.q + ' - TED2srt search';
    data.forEach(addSearchResult);
  }).catch(err => {
    console.log(err);
  });

  var addSearchResult;
  var $result;
  $result = document.getElementById('result');
  addSearchResult = function(talk) {
    var template = [
      '<h3><a href="/talks/{{slug}}">{{title}}</a></h3>',
      '<div class="talk-info-body">',<commit_msg>replace plus sign to space<commit_after>import utils from './util.js';
var TED_URL_REGEX = /^https?:\/\/www.ted.com\/talks\/(\w+)/;

export function searchPageHandler($http, params) {
  let match = TED_URL_REGEX.exec(decodeURIComponent(params.q)),
      query = params.q.replace(/\+/g, ' ');
  if (match) {
    document.location = '/talks/' + match[1];
  }
  var $input = document.querySelector('#search input[name=q]');
  $input.value = query;
  $input.focus();

  $http.get(`/api/search?q=${query}`).then((data) => {
    document.title = query + ' - TED2srt search';
    data.forEach(addSearchResult);
  }).catch(err => {
    console.log(err);
  });

  var addSearchResult;
  var $result;
  $result = document.getElementById('result');
  addSearchResult = function(talk) {
    var template = [
      '<h3><a href="/talks/{{slug}}">{{title}}</a></h3>',
      '<div class="talk-info-body">',
{'fraction_non_alphanumeric': 0.2122260668973472, 'fraction_numerical': 0.00461361014994233, 'mean_word_length': 3.740437158469945, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1185824', 'n_tokens_mistral': 613, 'n_tokens_neox': 623, 'n_words': 101}