Add getChatGPTWebModelsList_HTML function to mzta-utils.js and update imports in mzta-options.js
This commit is contained in:
parent
dfe1c5c8a4
commit
ca8e62aac4
2 changed files with 41 additions and 42 deletions
|
|
@ -216,6 +216,46 @@ export function getGPTWebModelString(model) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getChatGPTWebModelsList_HTML(values, targetRowId) {
|
||||||
|
const rowElement = document.getElementById(targetRowId);
|
||||||
|
if (!rowElement) return;
|
||||||
|
|
||||||
|
// Clears any existing td elements
|
||||||
|
rowElement.innerHTML = '';
|
||||||
|
|
||||||
|
// First TD: label
|
||||||
|
const labelTd = document.createElement('td');
|
||||||
|
const label = document.createElement('i');
|
||||||
|
label.className = 'small_info';
|
||||||
|
const labelNobr = document.createElement('nobr');
|
||||||
|
labelNobr.textContent = browser.i18n.getMessage("AllowedValues") + ":";
|
||||||
|
label.appendChild(labelNobr);
|
||||||
|
labelTd.appendChild(label);
|
||||||
|
|
||||||
|
// Second TD: values
|
||||||
|
const valuesTd = document.createElement('td');
|
||||||
|
const valuesContainer = document.createElement('i');
|
||||||
|
valuesContainer.className = 'small_info';
|
||||||
|
|
||||||
|
values.forEach(value => {
|
||||||
|
const nbspBefore = document.createTextNode(' \u00A0 '); // " "
|
||||||
|
const valueNobr = document.createElement('nobr');
|
||||||
|
valueNobr.className = 'conntype_chatgpt_web_option';
|
||||||
|
valueNobr.textContent = value;
|
||||||
|
const nbspAfter = document.createTextNode(' \u00A0 ');
|
||||||
|
|
||||||
|
valuesContainer.appendChild(nbspBefore);
|
||||||
|
valuesContainer.appendChild(valueNobr);
|
||||||
|
valuesContainer.appendChild(nbspAfter);
|
||||||
|
});
|
||||||
|
|
||||||
|
valuesTd.appendChild(valuesContainer);
|
||||||
|
|
||||||
|
// Adds the td elements to the row
|
||||||
|
rowElement.appendChild(labelTd);
|
||||||
|
rowElement.appendChild(valuesTd);
|
||||||
|
}
|
||||||
|
|
||||||
export function openTab(url){
|
export function openTab(url){
|
||||||
// check if the tab is already there
|
// check if the tab is already there
|
||||||
browser.tabs.query({url: browser.runtime.getURL(url)}).then((tabs) => {
|
browser.tabs.query({url: browser.runtime.getURL(url)}).then((tabs) => {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { OpenAI } from '../js/api/openai.js';
|
||||||
import { Ollama } from '../js/api/ollama.js';
|
import { Ollama } from '../js/api/ollama.js';
|
||||||
import { OpenAIComp } from '../js/api/openai_comp.js'
|
import { OpenAIComp } from '../js/api/openai_comp.js'
|
||||||
import { GoogleGemini } from '../js/api/google_gemini.js';
|
import { GoogleGemini } from '../js/api/google_gemini.js';
|
||||||
import { checkSparksPresence, isThunderbird128OrGreater, openTab, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, validateCustomData_ChatGPTWeb } from '../js/mzta-utils.js';
|
import { checkSparksPresence, isThunderbird128OrGreater, openTab, sanitizeChatGPTModelData, sanitizeChatGPTWebCustomData, validateCustomData_ChatGPTWeb, getChatGPTWebModelsList_HTML } from '../js/mzta-utils.js';
|
||||||
|
|
||||||
let taLog = new taLogger("mzta-options",true);
|
let taLog = new taLogger("mzta-options",true);
|
||||||
let _isThunderbird128OrGreater = true;
|
let _isThunderbird128OrGreater = true;
|
||||||
|
|
@ -320,47 +320,6 @@ async function disable_GetCalendarEvent(){
|
||||||
no_sparks_text.style.display = (is_spark_present == -1) ? 'inline' : 'none';
|
no_sparks_text.style.display = (is_spark_present == -1) ? 'inline' : 'none';
|
||||||
wrong_sparks_text.style.display = (is_spark_present == 0) ? 'inline' : 'none';
|
wrong_sparks_text.style.display = (is_spark_present == 0) ? 'inline' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getChatGPTWebModelsList_HTML(values, targetRowId) {
|
|
||||||
const rowElement = document.getElementById(targetRowId);
|
|
||||||
if (!rowElement) return;
|
|
||||||
|
|
||||||
// Clears any existing td elements
|
|
||||||
rowElement.innerHTML = '';
|
|
||||||
|
|
||||||
// First TD: label
|
|
||||||
const labelTd = document.createElement('td');
|
|
||||||
const label = document.createElement('i');
|
|
||||||
label.className = 'small_info';
|
|
||||||
const labelNobr = document.createElement('nobr');
|
|
||||||
labelNobr.textContent = browser.i18n.getMessage("AllowedValues") + ":";
|
|
||||||
label.appendChild(labelNobr);
|
|
||||||
labelTd.appendChild(label);
|
|
||||||
|
|
||||||
// Second TD: values
|
|
||||||
const valuesTd = document.createElement('td');
|
|
||||||
const valuesContainer = document.createElement('i');
|
|
||||||
valuesContainer.className = 'small_info';
|
|
||||||
|
|
||||||
values.forEach(value => {
|
|
||||||
const nbspBefore = document.createTextNode(' \u00A0 '); // " "
|
|
||||||
const valueNobr = document.createElement('nobr');
|
|
||||||
valueNobr.className = 'conntype_chatgpt_web_option';
|
|
||||||
valueNobr.textContent = value;
|
|
||||||
const nbspAfter = document.createTextNode(' \u00A0 ');
|
|
||||||
|
|
||||||
valuesContainer.appendChild(nbspBefore);
|
|
||||||
valuesContainer.appendChild(valueNobr);
|
|
||||||
valuesContainer.appendChild(nbspAfter);
|
|
||||||
});
|
|
||||||
|
|
||||||
valuesTd.appendChild(valuesContainer);
|
|
||||||
|
|
||||||
// Adds the td elements to the row
|
|
||||||
rowElement.appendChild(labelTd);
|
|
||||||
rowElement.appendChild(valuesTd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue