diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f8b866b3..e9f56f5a 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1420,11 +1420,15 @@ "description": "" }, "customPrompts_show_additional_info": { - "message": "Show ChatGPT additional properties", + "message": "Show ChatGPT Web additional properties", "description": "" }, "customPrompts_hide_additional_info": { - "message": "Hide ChatGPT additional properties", + "message": "Hide ChatGPT Web additional properties", + "description": "" + }, + "customPrompts_show_additional_info_show": { + "message": "ChatGPT Web additional properties", "description": "" } } \ No newline at end of file diff --git a/pages/customprompts/mzta-custom-prompts.css b/pages/customprompts/mzta-custom-prompts.css index 50f6d24a..89f0790b 100644 --- a/pages/customprompts/mzta-custom-prompts.css +++ b/pages/customprompts/mzta-custom-prompts.css @@ -148,6 +148,10 @@ tbody.list tr{ font-size: small; } +label, .id_show, .text_show, .name_show, .type_show, .action_show{ + font-size: small; +} + #txtIdNew, .id_output{ text-transform: lowercase; } @@ -222,7 +226,7 @@ tbody.list tr{ 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, .chatgpt_web_additional_info, .chatgpt_web_additional_info_toggle, .chatgpt_web_additional_info_show{ background-color: rgb(255, 209, 183); display:none; } @@ -249,6 +253,22 @@ tbody.list tr{ text-align: center; } +.chatgpt_web_additional_info_show{ + flex-direction: column; + justify-content: space-between; + height: 100%; + padding: 3px; + margin-top: 5px; +} + +.chatgpt_web_additional_info_row{ + display: flex; +} + +.chatgpt_web_additional_info_row span{ + margin-right: 0.4em; +} + 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 b8ea8da8..d928fead 100644 --- a/pages/customprompts/mzta-custom-prompts.js +++ b/pages/customprompts/mzta-custom-prompts.js @@ -23,6 +23,7 @@ import { taLogger } from "../../js/mzta-logger.js"; import { getPlaceholders } from "../../js/mzta-placeholders.js"; import { textareaAutocomplete } from "../../js/mzta-placeholders-autocomplete.js"; +let prefs = null; var promptsList = null; var somethingChanged = false; var positionMax_compose = 0; @@ -34,7 +35,7 @@ let autocompleteSuggestions = []; document.addEventListener('DOMContentLoaded', async () => { - let prefs = await browser.storage.sync.get({ connection_type:prefs_default.connection_type, do_debug: prefs_default.do_debug }); + prefs = await browser.storage.sync.get({ connection_type:prefs_default.connection_type, do_debug: prefs_default.do_debug }); taLog = new taLogger("mzta-custom-prompts", prefs.do_debug); setStorageSpace(); @@ -119,10 +120,10 @@ document.addEventListener('DOMContentLoaded', async () => { } }); }); - document.querySelectorAll('input.chatGPTWebProject_output').forEach(element => { + document.querySelectorAll('input.chatgpt_web_project_output').forEach(element => { element.addEventListener("input", validateCustomData_ChatGPTWeb); }); - document.querySelectorAll('input.chatGPTWebCustomGPT_output').forEach(element => { + document.querySelectorAll('input.chatgpt_web_custom_gpt_output').forEach(element => { element.addEventListener("input", validateCustomData_ChatGPTWeb); }); break; @@ -341,6 +342,10 @@ document.addEventListener('DOMContentLoaded', async () => { }; } + document.querySelectorAll('.chatgpt_web_additional_info_show').forEach(element => { + toggleAdditionalPropertiesShow(element); + }); + }, { once: true }); //========= handling an item in a row @@ -366,7 +371,8 @@ 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'; + toggleAdditionalPropertiesEditor(tr); + tr.querySelector('.chatgpt_web_additional_info_show').style.display = 'none'; tr.querySelector('.type_output').style.display = 'inline'; tr.querySelector('.type_show').style.display = 'none'; const action_output = tr.querySelector('.action_output') @@ -389,6 +395,7 @@ function hideItemRowEditor(tr) { tr.querySelector('.text_show').style.display = 'inline'; tr.querySelector('.chatgpt_web_additional_info_toggle').style.display = 'none'; tr.querySelector('.chatgpt_web_additional_info').style.display = 'none'; + toggleAdditionalPropertiesShow(tr); tr.querySelector('.type_output').style.display = 'none'; tr.querySelector('.type_show').style.display = 'inline'; const action_output = tr.querySelector('.action_output') @@ -402,6 +409,70 @@ function hideItemRowEditor(tr) { tr.querySelector('input.use_diff_viewer').disabled = true; } +function toggleAdditionalPropertiesShow(tr) { + switch(prefs.connection_type) { + case 'chatgpt_web': { + let element = tr.querySelector('.chatgpt_web_additional_info_show'); + let chatGPTWebModel_show = tr.querySelector('.chatgpt_web_model_show').innerText; + let chatGPTWebProject_show = tr.querySelector('.chatgpt_web_project_show').innerText; + let chatGPTWebCustomGPT_show = tr.querySelector('.chatgpt_web_custom_gpt_show').innerText; + + if ((chatGPTWebModel_show !== '' && chatGPTWebModel_show !== 'undefined') || + (chatGPTWebProject_show !== '' && chatGPTWebProject_show !== 'undefined') || + (chatGPTWebCustomGPT_show !== '' && chatGPTWebCustomGPT_show !== 'undefined')) { + element.style.display = 'flex'; + } else { + element.style.display = 'none'; + } + break; + } + // case 'chatgpt_api': + // document.getElementById('chatgpt_api').style.display = 'block'; + // break; + // case 'ollama_api': + // document.getElementById('ollama_api').style.display = 'block'; + // break; + // case 'openai_comp_api': + // document.getElementById('openai_comp_api').style.display = 'block'; + // break; + // case 'google_gemini_api': + // document.getElementById('google_gemini_api').style.display = 'block'; + // break; + } +} + +function toggleAdditionalPropertiesEditor(tr) { + switch(prefs.connection_type) { + case 'chatgpt_web': { + let element = tr.querySelector('.chatgpt_web_additional_info_show'); + let info_toggle = tr.querySelector('.chatgpt_web_additional_info_toggle'); + info_toggle.style.display = 'block'; + let chatGPTWebModel_show = tr.querySelector('.chatgpt_web_model_show').innerText; + let chatGPTWebProject_show = tr.querySelector('.chatgpt_web_project_show').innerText; + let chatGPTWebCustomGPT_show = tr.querySelector('.chatgpt_web_custom_gpt_show').innerText; + + if ((chatGPTWebModel_show !== '' && chatGPTWebModel_show !== 'undefined') || + (chatGPTWebProject_show !== '' && chatGPTWebProject_show !== 'undefined') || + (chatGPTWebCustomGPT_show !== '' && chatGPTWebCustomGPT_show !== 'undefined')) { + info_toggle.click(); + } + break; + } + // case 'chatgpt_api': + // document.getElementById('chatgpt_api').style.display = 'block'; + // break; + // case 'ollama_api': + // document.getElementById('ollama_api').style.display = 'block'; + // break; + // case 'openai_comp_api': + // document.getElementById('openai_comp_api').style.display = 'block'; + // break; + // case 'google_gemini_api': + // document.getElementById('google_gemini_api').style.display = 'block'; + // break; + } +} + function toggleDiffviewer(e) { e.preventDefault(); const tr = e.target.parentNode.parentNode; @@ -449,6 +520,9 @@ function handleCancelClick(e) { // tr.querySelector('.type_output').selectedOptions[0].text = tr.querySelector('.type_show').innerText; tr.querySelector('.action_output').value = tr.querySelector('.action').innerText; // tr.querySelector('.action_output').selectedOptions[0].text = tr.querySelector('.action_show').innerText; + tr.querySelector('.chatgpt_web_model_output').value = tr.querySelector('.chatgpt_web_model_show').innerText; + tr.querySelector('.chatgpt_web_project_output').value = tr.querySelector('.chatgpt_web_project_show').innerText; + tr.querySelector('.chatgpt_web_custom_gpt_output').value = tr.querySelector('.chatgpt_web_custom_gpt_show').innerText; hideItemRowEditor(tr); } @@ -464,6 +538,9 @@ function handleConfirmClick(e) { tr.querySelector('.id_show').innerText = String(tr.querySelector('.id_output').value).toLocaleLowerCase(); tr.querySelector('.name_show').innerText = tr.querySelector('.name_output').value; tr.querySelector('.text_show').innerText = tr.querySelector('.text_output').value; + tr.querySelector('.chatgpt_web_model_show').innerText = tr.querySelector('.chatgpt_web_model_output').value; + tr.querySelector('.chatgpt_web_project_show').innerText = tr.querySelector('.chatgpt_web_project_output').value; + tr.querySelector('.chatgpt_web_custom_gpt_show').innerText = tr.querySelector('.chatgpt_web_custom_gpt_output').value; tr.querySelector('.type').innerText = tr.querySelector('.type_output').value; tr.querySelector('.type_show').innerText = tr.querySelector('.type_output').selectedOptions[0].text; tr.querySelector('.action').innerText = tr.querySelector('.action_output').value; @@ -535,23 +612,28 @@ function loadPromptsList(values){ +
__MSG_customPrompts_show_additional_info_show__ +
__MSG_prefs_OptionText_chatgpt_web_model__:` + values.chatgpt_web_model + `
+
__MSG_prefs_OptionText_chatgpt_web_project__:` + values.chatgpt_web_project + `
+
__MSG_prefs_OptionText_chatgpt_web_custom_gpt__:` + values.chatgpt_web_custom_gpt + `
+
__MSG_customPrompts_show_additional_info__
- __MSG_prefs_OptionText_chatgpt_web_model__: + __MSG_prefs_OptionText_chatgpt_web_model__:
- + TODO


- __MSG_prefs_OptionText_chatgpt_web_project__: + __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_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_gpt__:
- -
__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ /g/CUSTOM_GPT_ID + +
__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ /g/CUSTOM_GPT_ID
__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__
@@ -606,6 +688,28 @@ function loadPromptsList(values){ } }; + switch(prefs.connection_type) { + case 'chatgpt_web': { + options.valueNames.push('chatgpt_web_model', 'chatgpt_web_project', 'chatgpt_web_custom_gpt'); + break; + } + // case 'chatgpt_api': + // document.getElementById('chatgpt_api').style.display = 'block'; + // break; + // case 'ollama_api': + // document.getElementById('ollama_api').style.display = 'block'; + // break; + // case 'openai_comp_api': + // document.getElementById('openai_comp_api').style.display = 'block'; + // break; + // case 'google_gemini_api': + // document.getElementById('google_gemini_api').style.display = 'block'; + // break; + } + + console.log('>>>>>>>>>>>>> options: ' + JSON.stringify(options)); + console.log('>>>>>>>>>>>>> values: ' + JSON.stringify(values)); + promptsList = new List('all_prompts', options, values); checkSelectedBoxes(); @@ -676,7 +780,7 @@ function checkFields() { } -function clearFields() { +function clearFields() { //TODO add new fields document.getElementById('txtIdNew').value = ''; document.getElementById('txtNameNew').value = ''; document.getElementById('txtTextNew').value = ''; @@ -749,6 +853,7 @@ async function saveAll() { promptsList.reIndex(); let newPrompts = promptsList.items.map(item => { // For each item in the array, return only the '_values' part + console.log(">>>>>>>>>>>>>>>> item: " + JSON.stringify(item)) return item.values(); }); taLog.log('newPrompts: ' + JSON.stringify(newPrompts));