Add reset button for max prompt length in options

This commit is contained in:
Mic 2025-05-22 00:46:00 +02:00
parent 75f83a486f
commit c65bfb5337
2 changed files with 9 additions and 2 deletions

View file

@ -451,6 +451,7 @@
<td>
<label>
<input type="number" id="max_prompt_length" name="max_prompt_length" class="option-input" />
<button type="button" id="reset_max_prompt_length" class="btn_small" style="margin-left:0.5em;">__MSG_reset_default__</button>
<br>__MSG_prefs_OptionText_max_prompt_length_Info__
</label>
</td>

View file

@ -389,7 +389,12 @@ function resetOpenAICompConfigs(){
let select_openai_comp_model = document.getElementById('openai_comp_services_shortcut');
select_openai_comp_model.value = 'custom';
}
function resetMaxPromptLength(){
let maxPromptLength = document.getElementById('max_prompt_length');
maxPromptLength.value = prefs_default.max_prompt_length;
browser.storage.sync.set({max_prompt_length: prefs_default.max_prompt_length});
}
document.addEventListener('DOMContentLoaded', async () => {
await restoreOptions();
@ -871,7 +876,8 @@ document.addEventListener('DOMContentLoaded', async () => {
document.getElementById('openai_comp_use_v1').dispatchEvent(new Event('change', { bubbles: true }));
document.getElementById('openai_comp_chat_name').dispatchEvent(new Event('change', { bubbles: true }));
}
});
document.getElementById('reset_max_prompt_length').addEventListener('click', resetMaxPromptLength);
}, { once: true });