PageSourceSearch

https://jayreddinjr-jr-odysseus-hf.hf.space/static/js/search.js

js jayreddinjr-jr-odysseus-hf.hf.space collected 2026-10-04 16:59:13 UTC 1,137 bytes, 52 lines download raw bytes

1// static/js/search.js
2
3/**
4 * Search settings management — reads active provider from admin settings.
5 */
6
7let API_BASE = '';
8let _provider = 'searxng';
9let _loaded = false;
10
11export function init(apiBase) {
12  API_BASE = apiBase;
13  // Fetch provider on init so it's ready when chat needs it
14  _fetchProvider();
15}
16
17async function _fetchProvider() {
18  try {
19    const res = await fetch((API_BASE || '') + '/api/auth/settings', { credentials: 'same-origin' });
20    const s = await res.json();
21    _provider = s.search_provider || 'searxng';
22    _loaded = true;
23  } catch (e) { /* keep default */ }
24}
25
26export function getCurrentProvider() {
27  return _provider;
28}
29
30const _labels = {
31  searxng: 'SearXNG', brave: 'Brave', duckduckgo: 'DuckDuckGo',
32  google_pse: 'Google', tavily: 'Tavily', serper: 'Serper',
33  disabled: 'search (disabled)',
34};
35
36export function getProviderLabel() {
37  return _labels[_provider] || _provider;
38}
39
40/** Re-fetch after admin saves new settings */
41export function refresh() {
42  _fetchProvider();
43}
44
45const searchModule = {
46  init,
47  getCurrentProvider,
48  getProviderLabel,
49  refresh
50};
51
52export default searchModule;

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.