From 808482b03557282be47a42412df45c18d034071a Mon Sep 17 00:00:00 2001 From: Mic Date: Sun, 27 Apr 2025 22:20:00 +0200 Subject: [PATCH] Enhance ChatGPT web additional info toggle functionality and styling. see #277 #168 --- pages/customprompts/mzta-custom-prompts.css | 15 +++++-- pages/customprompts/mzta-custom-prompts.js | 45 ++++++++++++++++++++- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/pages/customprompts/mzta-custom-prompts.css b/pages/customprompts/mzta-custom-prompts.css index 9aa04f59..50f6d24a 100644 --- a/pages/customprompts/mzta-custom-prompts.css +++ b/pages/customprompts/mzta-custom-prompts.css @@ -102,6 +102,10 @@ table .sort.desc { background-image: url(../images/listjs-arrow-sort-active-up.png); } +tbody.list tr{ + vertical-align: top; +} + .hiddendata{ display: none; } @@ -218,16 +222,16 @@ table .sort.desc { font-style: italic; } -#chatgpt_web_additional_info, #chatgpt_web_additional_info_toggle{ +#chatgpt_web_additional_info, #chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info, .chatgpt_web_additional_info_toggle{ background-color: rgb(255, 209, 183); display:none; } -#chatgpt_web_additional_info_toggle{ +#chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info_toggle{ cursor: pointer; } -#chatgpt_web_additional_info_toggle:hover{ +#chatgpt_web_additional_info_toggle:hover, .chatgpt_web_additional_info_toggle:hover{ background-color: rgb(255, 189, 153); text-decoration: underline; } @@ -240,6 +244,11 @@ table .sort.desc { vertical-align: top; } +.chatgpt_web_additional_info_toggle{ + width: -moz-available; + text-align: center; +} + input.input_additional[type="text"]{ width: -moz-available; } diff --git a/pages/customprompts/mzta-custom-prompts.js b/pages/customprompts/mzta-custom-prompts.js index 28b61333..a1d2622d 100644 --- a/pages/customprompts/mzta-custom-prompts.js +++ b/pages/customprompts/mzta-custom-prompts.js @@ -103,7 +103,22 @@ document.addEventListener('DOMContentLoaded', async () => { switch(prefs.connection_type) { case 'chatgpt_web': + // for the new item form document.getElementById('chatgpt_web_additional_info_toggle').style.display = 'table-row'; + // for the edit list items form + document.querySelectorAll('.chatgpt_web_additional_info_toggle').forEach(element => { + element.addEventListener('click', (e) => { + e.preventDefault(); + const additionalInfoRow = e.target.closest('td').querySelector('.chatgpt_web_additional_info'); + if (additionalInfoRow.style.display === 'none' || additionalInfoRow.style.display === '') { + additionalInfoRow.style.display = 'block'; + e.target.innerText = browser.i18n.getMessage('customPrompts_hide_additional_info'); + } else { + additionalInfoRow.style.display = 'none'; + e.target.innerText = browser.i18n.getMessage('customPrompts_show_additional_info'); + } + }); + }); break; // case 'chatgpt_api': // document.getElementById('chatgpt_api').style.display = 'block'; @@ -345,6 +360,7 @@ function showItemRowEditor(tr) { text_output.style.display = 'inline'; textareaAutocomplete(text_output, autocompleteSuggestions) tr.querySelector('.text_show').style.display = 'none'; + tr.querySelector('.chatgpt_web_additional_info_toggle').style.display = 'block'; tr.querySelector('.type_output').style.display = 'inline'; tr.querySelector('.type_show').style.display = 'none'; const action_output = tr.querySelector('.action_output') @@ -365,6 +381,7 @@ function hideItemRowEditor(tr) { tr.querySelector('.name_show').style.display = 'inline'; tr.querySelector('.text_output').style.display = 'none'; tr.querySelector('.text_show').style.display = 'inline'; + tr.querySelector('.chatgpt_web_additional_info_toggle').style.display = 'none'; tr.querySelector('.type_output').style.display = 'none'; tr.querySelector('.type_show').style.display = 'inline'; const action_output = tr.querySelector('.action_output') @@ -505,7 +522,32 @@ function loadPromptsList(values){ let output = ` -
+ + +
+ + +
+
__MSG_customPrompts_show_additional_info__
+
+ __MSG_prefs_OptionText_chatgpt_web_model__: +
+ + TODO
+

+ __MSG_prefs_OptionText_chatgpt_web_project__: +
+ +
__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ /g/PROJECT_ID-PROJECT_NAME/project +
__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__
+

+ __MSG_prefs_OptionText_chatgpt_web_custom_gpt__: +
+ +
__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ /g/CUSTOM_GPT_ID +
__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__
+
+ __MSG_customPrompts_add_to_menu__:
` + type_output + ` @@ -524,7 +566,6 @@ function loadPromptsList(values){ ` + ` -