const SIZE = 40; let mimeMap = []; let tagMap = []; let mimeTree; let tagTree; let searchBar = document.getElementById("searchBar"); let pathBar = document.getElementById("pathBar"); let lastDoc = null; let reachedEnd = false; let docCount = 0; let coolingDown = false; let searchBusy = true; let selectedIndices = []; let indexMap = {}; const CONF = new Settings(); const _defaults = { display: "grid", fuzzy: true, highlight: true }; function Settings() { this.options = {}; this._onUpdate = function () { $("#fuzzyToggle").prop("checked", this.options.fuzzy); } this.load = function () { const raw = window.localStorage.getItem("options"); if (raw === null) { this.options = _defaults; } else { this.options = JSON.parse(raw); } this._onUpdate(); } this.save = function () { window.localStorage.setItem("options", JSON.stringify(this.options)); this._onUpdate(); } } function showEsError() { $.toast({ heading: "Elasticsearch connection error", text: "sist2 web module encountered an error while connecting " + "to Elasticsearch. See server logs for more information.", stack: false, bgColor: "#a94442", textColor: "#f2dede", position: 'bottom-right', hideAfter: false }); } jQuery["jsonPost"] = function (url, data) { return jQuery.ajax({ url: url, type: "post", data: JSON.stringify(data), contentType: "application/json" }).fail(err => { showEsError(); console.log(err); }); }; window.onload = () => { $("#theme").on("click", () => { if (!document.cookie.includes("sist")) { document.cookie = "sist=dark"; } else { document.cookie = "sist=; Max-Age=-99999999;"; } window.location.reload(); }) CONF.load(); }; function toggleFuzzy() { searchDebounced(); } $.jsonPost("i").then(resp => { const urlIndices = (new URLSearchParams(location.search)).get("i"); resp["indices"].forEach(idx => { indexMap[idx.id] = idx.name; const opt = $("