working on custom prompts add new form. see #277 and #168

This commit is contained in:
Mic 2025-04-24 01:57:00 +02:00
parent 79f88e3c9a
commit c33c294ea1
4 changed files with 82 additions and 6 deletions

View file

@ -676,11 +676,11 @@
"description": ""
},
"prefs_OptionText_chatgpt_web_model": {
"message": "ChatGPT Web model",
"message": "ChatGPT Web Model",
"description": ""
},
"prefs_OptionText_chatgpt_web_model_info": {
"message": "This is the model that will be enforced for the ChatGPT Web Interface. If none is specified or an incorrect one is provided, the default model will be set by ChatGPT on the webpage.",
"message": "This is the Model that will be enforced for the ChatGPT Web Interface. If none is specified or an incorrect one is provided, the default model will be set by ChatGPT on the webpage.",
"description": ""
},
"prefs_OptionText_chatgpt_web_tempchat": {
@ -1392,11 +1392,11 @@
"description": ""
},
"prefs_OptionText_chatgpt_web_project": {
"message": "ChatGPT Web project",
"message": "ChatGPT Web Project",
"description": ""
},
"prefs_OptionText_chatgpt_web_project_info": {
"message": "This is the project that will be enforced for the ChatGPT Web Interface.",
"message": "This is the Project that will be enforced for the ChatGPT Web Interface.",
"description": ""
},
"prefs_OptionText_chatgpt_web_custom_gpt": {

View file

@ -213,6 +213,36 @@ table .sort.desc {
padding-right: 2px;
}
#chatgpt_web_additional_info_toggle td{
padding:0px 5px;
font-style: italic;
}
#chatgpt_web_additional_info, #chatgpt_web_additional_info_toggle{
background-color: rgb(255, 209, 183);
display:none;
}
#chatgpt_web_additional_info_toggle{
cursor: pointer;
}
#chatgpt_web_additional_info td{
vertical-align: top;
}
input.input_additional[type="text"]{
width: -moz-available;
}
.small_info{
font-size:smaller;
}
.conntype_chatgpt_web_option{
cursor: pointer;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #1C1B22;
@ -259,4 +289,8 @@ table .sort.desc {
.autocomplete-list li.active {
background-color: #4c4e58;
}
#chatgpt_web_additional_info{
background-color: rgb(39, 11, 0);
}
}

View file

@ -78,6 +78,28 @@
<input type="text" id="txtNameNew" name="name" class="input_new" tabindex="2">
</td>
</tr>
<tr id="chatgpt_web_additional_info_toggle"><td colspan="4"><span class="small_info">Show ChatGPT additional properties</span></td></tr>
<tr id="chatgpt_web_additional_info"><!-- ChatGPT Web additional info -->
<td colspan="2">
<label for="chatGPTWebModelNew" class="field_title">__MSG_prefs_OptionText_chatgpt_web_model__:</label>
<br>
<input type="text" id="chatGPTWebModelNew" name="chatGPTWebModelNew" class="input_new input_additional" tabindex="10">
<table title="__MSG_prefs_OptionText_chatgpt_web_model_tooltip__"><tr id="chatgpt_web_models_list">TODO</tr></table>
<br><br>
<label for="chatGPTWebProjectNew" class="field_title">__MSG_prefs_OptionText_chatgpt_web_project__:</label>
<br>
<input type="text" id="chatGPTWebProjectNew" name="chatGPTWebProjectNew" class="input_new input_additional" tabindex="11">
<br><i class="small_info" id="chatgpt_web_project_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/PROJECT_ID-PROJECT_NAME/project</b>
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
</td>
<td colspan="2">
<label for="chatGPTWebCustomGPTNew" class="field_title">__MSG_prefs_OptionText_chatgpt_web_custom_gpt__:</label>
<br>
<input type="text" id="chatGPTWebCustomGPTNew" name="chatGPTWebCustomGPTNew" class="input_new input_additional" tabindex="11">
<br><i class="small_info" id="chatgpt_web_custom_gpt_info">__MSG_prefs_OptionText_chatgpt_web_custom_data_info__ <b>/g/CUSTOM_GPT_ID</b>
<br>__MSG_prefs_OptionText_chatgpt_web_custom_data_info2__</i>
</td>
</tr>
</table>
<div class="go_right_float">* __MSG_customPrompts_form_required_fields__</div>
<br>

View file

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { prefs_default } from "../../options/mzta-options-default.js";
import { getPrompts, setDefaultPromptsProperties, setCustomPrompts, preparePromptsForExport, preparePromptsForImport } from "../../js/mzta-prompts.js";
import { isThunderbird128OrGreater, getCustomPromptsUsedSpace, sanitizeHtml } from "../../js/mzta-utils.js";
import { taLogger } from "../../js/mzta-logger.js";
@ -33,8 +34,8 @@ let autocompleteSuggestions = [];
document.addEventListener('DOMContentLoaded', async () => {
let prefs_debug = await browser.storage.sync.get({do_debug: false});
taLog = new taLogger("mzta-custom-prompts", prefs_debug.do_debug);
let 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();
@ -100,6 +101,25 @@ document.addEventListener('DOMContentLoaded', async () => {
i18n.updateDocument();
switch(prefs.connection_type) {
case 'chatgpt_web':
document.getElementById('chatgpt_web_additional_info_toggle').style.display = 'table-row';
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;
}
//To add a new item
var txtIdNew = document.getElementById('txtIdNew');
var txtNameNew = document.getElementById('txtNameNew');