diff --git a/js/mzta-utils.js b/js/mzta-utils.js index bf41319a..4f55343c 100644 --- a/js/mzta-utils.js +++ b/js/mzta-utils.js @@ -364,6 +364,35 @@ export function generateCallID(length = 10) { return result; } +export function populateConnectionTypeOptions(selectId) { + const selectEl = document.getElementById(selectId); + if (!selectEl) return; + + const prevValue = selectEl.value; + + const options = [ + { value: 'chatgpt_web', msgKey: 'prefs_Connection_type_ChatGPT_Web' }, + { value: 'chatgpt_api', msgKey: 'prefs_Connection_type_ChatGPT_API' }, + { value: 'google_gemini_api', msgKey: 'prefs_Connection_type_Google_Gemini_API' }, + { value: 'anthropic_api', msgKey: 'prefs_Connection_type_Anthropic_API' }, + { value: 'ollama_api', msgKey: 'prefs_Connection_type_Ollama_API' }, + { value: 'openai_comp_api', msgKey: 'prefs_Connection_type_OpenAI_Comp_API' } + ]; + + selectEl.innerHTML = ''; + + for (const opt of options) { + const optionEl = document.createElement('option'); + optionEl.value = opt.value; + optionEl.textContent = browser.i18n.getMessage(opt.msgKey) || opt.msgKey; + selectEl.appendChild(optionEl); + } + + if (options.some(o => o.value === prevValue)) { + selectEl.value = prevValue; + } +} + export async function getTagsList(){ let messageTags = []; if(await isThunderbird128OrGreater()) { @@ -753,4 +782,4 @@ export async function* getMessages(list) { yield message; } } -} \ No newline at end of file +} diff --git a/options/mzta-options.html b/options/mzta-options.html index f8c12e4b..a9c90554 100644 --- a/options/mzta-options.html +++ b/options/mzta-options.html @@ -121,14 +121,7 @@