prompts in the menu are ordered alphabetically. options renamed to dynamic_menu_order_alphabet

This commit is contained in:
mic 2024-09-23 22:08:29 +02:00
parent e968a4d1be
commit 31f1e5592f
4 changed files with 14 additions and 6 deletions

View file

@ -563,11 +563,11 @@
"message": "If checked, using the keyboard shortcut CTRL+ALT+A will automatically send the hightlighted prompt from the menu. Otherwise, the prompt name will be displayed to the user, requiring another press of the Enter key to send it.",
"description": ""
},
"prefs_OptionText_dynamic_menu_order_prompt_alphabetically": {
"prefs_OptionText_dynamic_menu_order_alphabet": {
"message": "Menu: order alphabetically",
"description": ""
},
"prefs_OptionText_dynamic_menu_order_prompt_alphabetically_info": {
"prefs_OptionText_dynamic_menu_order_alphabet_info": {
"message": "If checked, the prompts in the menu will be ordered alphabetically.",
"description": ""
}

View file

@ -30,5 +30,5 @@ export const prefs_default = {
openai_comp_model: '',
openai_comp_chat_name: 'OpenAI Comp',
dynamic_menu_force_enter: false,
dynamic_menu_order_prompt_alphabetically: true,
dynamic_menu_order_alphabet: true,
}

View file

@ -61,12 +61,12 @@
</tr>
<tr>
<td><label>
<span>__MSG_prefs_OptionText_dynamic_menu_order_prompt_alphabetically__</span>
<span>__MSG_prefs_OptionText_dynamic_menu_order_alphabet__</span>
</label></td>
<td>
<label>
<input type="checkbox" id="dynamic_menu_order_prompt_alphabetically" name="dynamic_menu_order_prompt_alphabetically" class="option-input" />
&nbsp;<span>__MSG_prefs_OptionText_dynamic_menu_order_prompt_alphabetically_info__</span>
<input type="checkbox" id="dynamic_menu_order_alphabet" name="dynamic_menu_order_alphabet" class="option-input" />
&nbsp;<span>__MSG_prefs_OptionText_dynamic_menu_order_alphabet_info__</span>
</label>
</td>
</tr>

View file

@ -42,6 +42,14 @@ document.addEventListener('DOMContentLoaded', async () => {
async function searchPrompt(allPrompts, tabId, tabType){
taLog.log("tabType: " + tabType);
let prefs_order = await browser.storage.sync.get({dynamic_menu_order_alphabet: true});
if(prefs_order.dynamic_menu_order_alphabet){
allPrompts.sort((a, b) => a.label.localeCompare(b.label));
}
// console.log(">>>>>>>>> allPrompts: " + JSON.stringify(allPrompts));
let input = document.getElementById('mzta_search_input');
let autocompleteList = document.getElementById('mzta_autocomplete-items');
let autocompleteListLoading = document.getElementById('mzta_autocomplete-items-loading');