PageSourceSearch

https://oio.social/assets/js/lunr/lunr-en.js

js oio.social collected 2026-10-04 13:24:21 UTC 2,525 bytes, 71 lines download raw bytes

1var idx = lunr(function () {
2  this.field('title')
3  this.field('excerpt')
4  this.field('categories')
5  this.field('tags')
6  this.ref('id')
7
8  this.pipeline.remove(lunr.trimmer)
9
10  for (var item in store) {
11    this.add({
12      title: store[item].title,
13      excerpt: store[item].excerpt,
14      categories: store[item].categories,
15      tags: store[item].tags,
16      id: item
17    })
18  }
19});
20
21console.log( jQuery.type(idx) );
22
23$(document).ready(function() {
24  $('input#search').on('keyup', function () {
25    var resultdiv = $('#results');
26    var query = $(this).val().toLowerCase();
27    var result =
28      idx.query(function (q) {
29        query.split(lunr.tokenizer.separator).forEach(function (term) {
30          q.term(term, { boost: 100 })
31          if(query.lastIndexOf(" ") != query.length-1){
32            q.term(term, {  usePipeline: false, wildcard: lunr.Query.wildcard.TRAILING, boost: 10 })
33          }
34          if (term != ""){
35            q.term(term, {  usePipeline: false, editDistance: 1, boost: 1 })
36          }
37        })
38      });
39    resultdiv.empty();
40    resultdiv.prepend('<p class="results__found">'+result.length+' Result(s) found</p>');
41    for (var item in result) {
42      var ref = result[item].ref;
43      if(store[ref].teaser){
44        var searchitem =
45          '<div class="list__item">'+
46            '<article class="archive__item" itemscope itemtype="http://schema.org/CreativeWork">'+
47              '<h2 class="archive__item-title" itemprop="headline">'+
48                '<a href="'+store[ref].url+'" rel="permalink">'+store[ref].title+'</a>'+
49              '</h2>'+
50              '<div class="archive__item-teaser">'+
51                '<img src="'+store[ref].teaser+'" alt="">'+
52              '</div>'+
53              '<p class="archive__item-excerpt" itemprop="description">'+store[ref].excerpt.split(" ").splice(0,20).join(" ")+'...</p>'+
54            '</article>'+
55          '</div>';
56      }
57      else{
58    	  var searchitem =
59          '<div class="list__item">'+
60            '<article class="archive__item" itemscope itemtype="http://schema.org/CreativeWork">'+
61              '<h2 class="archive__item-title" itemprop="headline">'+
62                '<a href="'+store[ref].url+'" rel="permalink">'+store[ref].title+'</a>'+
63              '</h2>'+
64              '<p class="archive__item-excerpt" itemprop="description">'+store[ref].excerpt.split(" ").splice(0,20).join(" ")+'...</p>'+
65            '</article>'+
66          '</div>';
67      }
68      resultdiv.append(searchitem);
69    }
70  });
71});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.