~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
refactor: extract favorite star creation into helper function
LearningCircuit0c7a14d5fc3c
diff --git a/src/local_deep_research/web/static/js/components/custom_dropdown.js b/src/local_deep_research/web/static/js/components/custom_dropdown.jsindex 1fc8cb1bb2..e3c31c29b1 100644--- a/src/local_deep_research/web/static/js/components/custom_dropdown.js+++ b/src/local_deep_research/web/static/js/components/custom_dropdown.js@@ -16,6 +16,61 @@// Keep a registry of inputs and their associated options functionsconst dropdownRegistry = {};+ /**+ * Create a favorite star element with proper accessibility attributes+ * @param {Object} item - The item object with value and is_favorite properties+ * @param {Function} onToggle - Callback when star is clicked (newIsFavorite) => {}+ * @returns {HTMLElement} The star span element+ */+ function createFavoriteStarElement(item, onToggle) {+ const starSpan = document.createElement('span');+ starSpan.className = 'ldr-dropdown-favorite-star';+ starSpan.setAttribute('data-value', item.value);+ starSpan.setAttribute('role', 'button');+ starSpan.setAttribute('tabindex', '0');++ const isFavorite = item.is_favorite === true;+ updateStarState(starSpan, isFavorite);++ const handleToggle = (e) => {+ e.preventDefault();+ e.stopPropagation();+ const newIsFavorite = !starSpan.classList.contains('ldr-is-favorite');+ onToggle(newIsFavorite);+ updateStarState(starSpan, newIsFavorite);+ };++ starSpan.addEventListener('click', handleToggle);+ starSpan.addEventListener('keydown', (e) => {+ if (e.key === 'Enter' || e.key === ' ') {+ handleToggle(e);+ }+ });++ return starSpan;+ }++ /**+ * Update the visual state of a star element+ * @param {HTMLElement} starSpan - The star span element+ * @param {boolean} isFavorite - Whether the item is a favorite+ */+ function updateStarState(starSpan, isFavorite) {+ if (isFavorite) {+ starSpan.classList.add('ldr-is-favorite');+ starSpan.innerHTML = '★'; // Filled star+ starSpan.title = 'Remove from favorites';+ starSpan.setAttribute('aria-label', 'Remove from favorites');+ starSpan.setAttribute('aria-pressed', 'true');+ } else {+ starSpan.classList.remove('ldr-is-favorite');+ starSpan.innerHTML = '☆'; // Empty star+ starSpan.title = 'Add to favorites';+ starSpan.setAttribute('aria-label', 'Add to favorites');+ starSpan.setAttribute('aria-pressed', 'false');+ }+ }+/*** Update the options for an existing dropdown without destroying it* @param {HTMLElement} input - The input element@@ -68,37 +123,9 @@// Add favorite star if callback is providedif (dropdownInfo.onFavoriteToggle) {- const starSpan = document.createElement('span');- starSpan.className = 'ldr-dropdown-favorite-star';- starSpan.setAttribute('data-value', item.value);-- const isFavorite = item.is_favorite === true;- if (isFavorite) {- starSpan.classList.add('ldr-is-favorite');- starSpan.innerHTML = '★';- starSpan.title = 'Remove from favorites';- } else {- starSpan.innerHTML = '☆';- starSpan.title = 'Add to favorites';- }-- starSpan.addEventListener('click', (e) => {- e.preventDefault();- e.stopPropagation();- const newIsFavorite = !isFavorite;+ const starSpan = createFavoriteStarElement(item, (newIsFavorite) => {dropdownInfo.onFavoriteToggle(item.value, item, newIsFavorite);-- if (newIsFavorite) {- starSpan.classList.add('ldr-is-favorite');- starSpan.innerHTML = '★';- starSpan.title = 'Remove from favorites';- } else {- starSpan.classList.remove('ldr-is-favorite');- starSpan.innerHTML = '☆';- starSpan.title = 'Add to favorites';- }});-div.appendChild(starSpan);}@@ -313,44 +340,9 @@// Add favorite star if callback is providedif (onFavoriteToggle) {- const starSpan = document.createElement('span');- starSpan.className = 'ldr-dropdown-favorite-star';- starSpan.setAttribute('data-value', item.value);-- // Check if item is a favorite- const isFavorite = item.is_favorite === true;- if (isFavorite) {- starSpan.classList.add('ldr-is-favorite');- starSpan.innerHTML = '★'; // Filled star- starSpan.title = 'Remove from favorites';- } else {- starSpan.innerHTML = '☆'; // Empty star- starSpan.title = 'Add to favorites';- }-- // Handle star click- starSpan.addEventListener('click', (e) => {- e.preventDefault();- e.stopPropagation();-- // Toggle favorite state- const newIsFavorite = !isFavorite;-- // Call the callback+ const starSpan = createFavoriteStarElement(item, (newIsFavorite) => {onFavoriteToggle(item.value, item, newIsFavorite);-- // Update visual state immediately- if (newIsFavorite) {- starSpan.classList.add('ldr-is-favorite');- starSpan.innerHTML = '★';- starSpan.title = 'Remove from favorites';- } else {- starSpan.classList.remove('ldr-is-favorite');- starSpan.innerHTML = '☆';- starSpan.title = 'Add to favorites';- }});-div.appendChild(starSpan);}