diff --git a/internal/views/static/js/settings.js b/internal/views/static/js/settings.js index 9682e6a..324d35f 100644 --- a/internal/views/static/js/settings.js +++ b/internal/views/static/js/settings.js @@ -7,7 +7,8 @@ var DEFAULT_PREFS = { theme: 'system', engines: ALL_ENGINES.slice(), safeSearch: 'moderate', - format: 'html' + format: 'html', + favicon: 'none' // 'none' | 'google' | 'duckduckgo' }; var STORAGE_KEY = 'kafka_prefs'; @@ -22,7 +23,8 @@ function loadPrefs() { theme: parsed.theme || DEFAULT_PREFS.theme, engines: parsed.engines || DEFAULT_PREFS.engines.slice(), safeSearch: parsed.safeSearch || DEFAULT_PREFS.safeSearch, - format: parsed.format || DEFAULT_PREFS.format + format: parsed.format || DEFAULT_PREFS.format, + favicon: parsed.favicon || DEFAULT_PREFS.favicon }; } catch (e) { prefs = DEFAULT_PREFS; @@ -43,6 +45,24 @@ function applyTheme(theme) { } } +function applyFavicon(service) { + var faviconMap = { + google: function(domain) { return 'https://www.google.com/s2/favicons?domain=' + encodeURIComponent(domain) + '&sz=32'; }, + duckduckgo: function(domain) { return 'https://icons.duckduckgo.com/ip3/' + encodeURIComponent(domain) + '.ico'; } + }; + var imgs = document.querySelectorAll('.result-favicon'); + imgs.forEach(function(img) { + var domain = img.getAttribute('data-domain'); + if (!domain) return; + if (service === 'none') { + img.style.display = 'none'; + } else { + img.style.display = ''; + img.src = faviconMap[service](domain); + } + }); +} + function syncEngineInput(prefs) { var input = document.getElementById('engines-input'); if (input) { @@ -104,6 +124,13 @@ function renderPanel(prefs) { }); + var faviconOptions = ''; + ['none', 'google', 'duckduckgo'].forEach(function(src) { + var labels = { none: 'None', google: 'Google', duckduckgo: 'DuckDuckGo' }; + var selected = prefs.favicon === src ? ' selected' : ''; + faviconOptions += ''; + }); + body.innerHTML = '
Fetch favicons for result URLs. "None" is most private.
+