<commit_before><!doctype html>
<html>
<head>
<title>Wikipedia pages local search</title>
<style>
.result {
  margin: 0.5em 0;
}
.prevPage, .page, .nextPage {
  margin: 0 4px;
}
.prevPage, .page, .nextPage {
  text-decoration: none;
}
.prevPage:hover, a.page:hover, .nextPage:hover {
  text-decoration: underline;
}
</style>
</head>
<body>
<script src="/js/mithril.js"></script>
<script src="/js/observable.js"></script>
<script>
Result = function(data) {
  this.title = m.prop(data && data.title || "")
  this.text = m.prop(data && data.text || "")
}

Observable.on(['search'], function(data) {
  var url = "/search"
  var q = data.searchWord
  if (q !== "") {
    url += "?q=" + encodeURIComponent("_key:@" + q + " OR text:@" + q) +
      "&offset=" + data.offset + "&limit=" + data.limit
  }
  return m.request({method: "GET", url: url})
  .then(function(data) {
    Observable.trigger('searchDone', data)
  })
})

var SearchWidget = {
  controller: function() {
    Observable.on(['searchDone'], function(data) {
      vm.resultsVisible(true)
      vm.numItems(data.matchedCount)
      vm.results(data.results.map(function(result) {
        return new Result(result)
      }))
      m.redraw()
    })

    this.search = function() {
      vm.currentPage(1)
      m.route('q=' + encodeURIComponent(vm.searchWord()) + '&start=' + 0)
      Observable.trigger('search', {
        searchWord: vm.searchWord(),
        offset: 0,
        limit: vm.itemsPerPage()
      })
      return false
    }
    this.jumpToPage = function(page) {
      var offset = (page - 1) * vm.itemsPerPage()
      vm.currentPage(page)
      m.route('q=' + encodeURIComponent(vm.searchWord()) + '&start=' + offset)
      Observable.trigger('search', {
        searchWord: vm.searchWord(),
        offset: offset,
        limit: vm.itemsPerPage()
      })
      return false
    }

    var vm = {
      searchWord: m.prop(''),
      currentPage: m.prop(1),
      itemsPerPage: m.prop(10),
      resultsVisible: m.prop(false),
      results: m.prop([]),<commit_msg>Remove uneeded m.redarw()<commit_after><!doctype html>
<html>
<head>
<title>Wikipedia pages local search</title>
<style>
.result {
  margin: 0.5em 0;
}
.prevPage, .page, .nextPage {
  margin: 0 4px;
}
.prevPage, .page, .nextPage {
  text-decoration: none;
}
.prevPage:hover, a.page:hover, .nextPage:hover {
  text-decoration: underline;
}
</style>
</head>
<body>
<script src="/js/mithril.js"></script>
<script src="/js/observable.js"></script>
<script>
Result = function(data) {
  this.title = m.prop(data && data.title || "")
  this.text = m.prop(data && data.text || "")
}

Observable.on(['search'], function(data) {
  var url = "/search"
  var q = data.searchWord
  if (q !== "") {
    url += "?q=" + encodeURIComponent("_key:@" + q + " OR text:@" + q) +
      "&offset=" + data.offset + "&limit=" + data.limit
  }
  return m.request({method: "GET", url: url})
  .then(function(data) {
    Observable.trigger('searchDone', data)
  })
})

var SearchWidget = {
  controller: function() {
    Observable.on(['searchDone'], function(data) {
      vm.resultsVisible(true)
      vm.numItems(data.matchedCount)
      vm.results(data.results.map(function(result) {
        return new Result(result)
      }))
    })

    this.search = function() {
      vm.currentPage(1)
      m.route('q=' + encodeURIComponent(vm.searchWord()) + '&start=' + 0)
      Observable.trigger('search', {
        searchWord: vm.searchWord(),
        offset: 0,
        limit: vm.itemsPerPage()
      })
      return false
    }
    this.jumpToPage = function(page) {
      var offset = (page - 1) * vm.itemsPerPage()
      vm.currentPage(page)
      m.route('q=' + encodeURIComponent(vm.searchWord()) + '&start=' + offset)
      Observable.trigger('search', {
        searchWord: vm.searchWord(),
        offset: offset,
        limit: vm.itemsPerPage()
      })
      return false
    }

    var vm = {
      searchWord: m.prop(''),
      currentPage: m.prop(1),
      itemsPerPage: m.prop(10),
      resultsVisible: m.prop(false),
      results: m.prop([]),
{'fraction_non_alphanumeric': 0.1828459080855247, 'fraction_numerical': 0.005898255099533055, 'mean_word_length': 2.891013384321224, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '2362056', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1401, 'n_words': 272}