PageSourceSearch

https://www.microscopyu.com/js/algolia.js?v=16

js microscopyu.com collected 2026-09-24 09:04:28 UTC 3,305 bytes, 113 lines download raw bytes

1const algoliaClient = algoliasearch("FOPMB5IQ00","215bfb0dedd7bb42a435b6622d3c849d");
2const searchClient = {
3  ...algoliaClient,
4  search(requests) {
5    if (requests.every(({
6        params
7      }) => !params.query)) {
8      return Promise.resolve({
9        results: requests.map(() => ({
10          hits: [],
11          nbHits: 0,
12          nbPages: 0,
13          page: 0,
14          processingTimeMS: 0,
15        })),
16      });
17    }
18    return algoliaClient.search(requests);
19  },
20};
21const domain = location.origin;
22const lang = document.documentElement.lang
23var alIndex = '';
24if(domain == 'https://www.microscopyu.com' || domain == ''){
25  alIndex = 'Articles';
26} else if(domain == 'https://mu.local'){
27  if(lang == 'ja'){
28    alIndex = 'dev_Articles_ja';
29  } else {
30    alIndex = 'dev_Articles';
31  }
32} else {
33  if(lang == 'ja'){
34    alIndex = 'staging_Articles_ja';
35  } else {
36    alIndex = 'staging_Articles';
37  }
38}
39const filters = 'section:Articles';
40const params = new URLSearchParams(window.location.search)
41const q = document.getElementById('search-form');
42const search = instantsearch({
43  initialUiState: {
44    dev_Articles: {
45      query: q.dataset.query,
46    },
47    staging_Articles: {
48      query: q.dataset.query,
49    },
50    Articles: {
51      query: q.dataset.query,
52    },
53  },
54  searchFunction: function(helper) {
55    const container = document.querySelector('#search-results');
56    const refinements = document.querySelector('#search-refinements');
57    container.style.display = helper.state.query === '' ? 'none' : '';
58    refinements.style.display = helper.state.query === '' ? 'none' : '';
59    helper.search();
60  },
61  filters: filters,
62  indexName: alIndex,
63  searchClient,
64})
65search.on('render', function(){
66  $("img.lazy").lazyload({
67      threshold : 600,
68      effect : "fadeIn",
69      failure_limit : 100
70    });
71} );
72function truncate(input, length) {
73   if (input.length > length) {
74      return input.substring(0, length) + '...';
75   }
76   return input;
77};
78// After the `searchBox` widget
79search.addWidgets([
80  instantsearch.widgets.configure({
81    attributesToSnippet: ['articleBody:40'],
82    snippetEllipsisText: '…',
83  }),
84  instantsearch.widgets.searchBox({
85    container: '#search-form',
86    placeholder: 'Search MicroscopyU',
87    showReset: false,
88    showSubmit: false
89  }),
90  instantsearch.widgets.refinementList({
91    container: '#search-refinements',
92    attribute: 'section',
93    sortBy: ['count:desc', 'name:asc'],
94  }),
95  instantsearch.widgets.infiniteHits({
96    container: '#search-results',
97    escapeHTML: false,
98    transformItems(items) {
99      return items.map(item => ({
100        ...item,
101        url: item.url,
102        image: item.image,
103      }));
104    },
105    templates: {
106      item: '<div class="search-result"><div class="search-result-thumb"><a href="{{ url }}" title="{{section}} - {{ title }}"><img class="lazy" data-original="{{image}}" /></a></div><h3><a href="{{ url }}" title="{{section}} - {{ title }}"><span class="search-result-type">{{section}}</span> {{#helpers.highlight}}{"attribute": "title"}{{/helpers.highlight}}</a></h3><div class="search-result-descript">{{#helpers.snippet}}{ "attribute": "articleBody.0" }{{/helpers.snippet}}</div></div>',
107    },
108  }),
109  instantsearch.widgets.configure({
110    hitsPerPage: 20
111  }),
112]);
113search.start();

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.