added close button. improved action buttons

This commit is contained in:
mic 2024-07-22 00:13:01 +02:00
parent 5b6b200af0
commit 94e5398b02

View file

@ -51,6 +51,13 @@ messagesAreaStyle.textContent = `
line-height: 1.3;
text-align: center;
}
.action-buttons button {
display: inline;
margin: 0 10px;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
}
@keyframes fadeIn {
to {
opacity: 1;
@ -147,7 +154,6 @@ class MessagesArea extends HTMLElement {
addActionButtons(promptData = null) {
if(promptData == null) { return; }
if(promptData.action == 0) { return; } // No action needed
const actionButtons = document.createElement('div');
actionButtons.classList.add('action-buttons');
const actionButton = document.createElement('button');
@ -166,7 +172,13 @@ class MessagesArea extends HTMLElement {
break;
}
});
actionButtons.appendChild(actionButton);
const closeButton = document.createElement('button');
closeButton.textContent = browser.i18n.getMessage("chatgpt_win_close");
closeButton.addEventListener('click', () => {
browser.runtime.sendMessage({command: "chatgpt_close"}); // close window
});
if(promptData.action != 0) { actionButtons.appendChild(actionButton); }
actionButtons.appendChild(closeButton);
this.messages.appendChild(actionButtons);
this.scrollToBottom();
}