reset button added. see #102

This commit is contained in:
mic 2026-01-02 12:33:53 +01:00
parent ae83e3284e
commit 3ebbaf184b
2 changed files with 24 additions and 3 deletions

View file

@ -44,7 +44,9 @@ export async function injectConnectionUI({
no_chatgpt_web = false,
defaultType = '',
tr_class = '',
taLog = console
taLog = console,
customButtonLabel = '',
customButtonCallback = null
} = {}) {
const anchorTr = document.getElementById(afterTrId);
@ -74,8 +76,9 @@ export async function injectConnectionUI({
</label>
</td>
<td>
<label>
<label style="display: flex; align-items: center;">
<select id="${selectId}" name="${selectId}" class="option-input"></select>
${customButtonLabel ? `<button id="${modelId_prefix}customButton" style="margin-left: 10px;">${customButtonLabel}</button>` : ''}
</label>
</td>
</tr>
@ -961,6 +964,16 @@ export async function injectConnectionUI({
warn_Anthropic_APIKeyEmpty(modelId_prefix);
warn_Anthropic_VersionEmpty(modelId_prefix);
if (customButtonLabel && customButtonCallback) {
const btn = document.getElementById(`${modelId_prefix}customButton`);
if (btn) {
btn.addEventListener('click', (e) => {
e.preventDefault();
customButtonCallback(e);
});
}
}
return {
select: conntype_select,
onTypeChange: (fn) => { onTypeChange = fn; fn(conntype_select.value, { select: conntype_select }); }

View file

@ -489,7 +489,15 @@ function handleEditClick(e) {
selectId: selectId,
modelId_prefix: prefix,
no_chatgpt_web: true,
taLog: taLog
taLog: taLog,
customButtonLabel: "Reset",
customButtonCallback: () => {
const selectEl = document.getElementById(selectId);
if (selectEl) {
selectEl.value = '';
selectEl.dispatchEvent(new Event('change'));
}
}
}).then(() => {
populateConnectionUI(tr, id, prefix, selectId);
updateWarnings(prefix);