formatting fixed

This commit is contained in:
mic 2024-10-17 20:55:07 +02:00
parent cac620e26f
commit 1a80ab7991

View file

@ -59,115 +59,115 @@ switch (message.command) {
return Promise.resolve(window.document.body.innerHTML); return Promise.resolve(window.document.body.innerHTML);
case 'sendAlert': case 'sendAlert':
console.log(">>>>>> message.curr_tab_type: " + JSON.stringify(message.curr_tab_type)); //console.log(">>>>>> message.curr_tab_type: " + JSON.stringify(message.curr_tab_type));
if(message.curr_tab_type == 'mail'){ // workaround for Thunderbird bug not showing the alert if(message.curr_tab_type == 'mail'){ // workaround for Thunderbird bug not showing the alert
// Create dialog elements // Create dialog elements
const dialog_sendAlert = window.document.createElement('dialog'); const dialog_sendAlert = window.document.createElement('dialog');
dialog_sendAlert.classList.add('mzta_dialog'); dialog_sendAlert.classList.add('mzta_dialog');
const content_sendAlert = window.document.createElement('div'); const content_sendAlert = window.document.createElement('div');
content_sendAlert.classList.add('mzta_dialog_content'); content_sendAlert.classList.add('mzta_dialog_content');
// Create close button // Create close button
const closeButton_sendAlert = window.document.createElement('button'); const closeButton_sendAlert = window.document.createElement('button');
closeButton_sendAlert.classList.add('mzta_dialog_close'); closeButton_sendAlert.classList.add('mzta_dialog_close');
closeButton_sendAlert.id = 'mzta_dialog_close'; closeButton_sendAlert.id = 'mzta_dialog_close';
closeButton_sendAlert.textContent = 'Close'; closeButton_sendAlert.textContent = 'Close';
// Create message element // Create message element
const message_sendAlert = window.document.createElement('div'); const message_sendAlert = window.document.createElement('div');
message_sendAlert.classList.add('mzta_dialog_message'); message_sendAlert.classList.add('mzta_dialog_message');
message_sendAlert.textContent = message.message; message_sendAlert.textContent = message.message;
// Append elements to the dialog // Append elements to the dialog
content_sendAlert.appendChild(message_sendAlert); content_sendAlert.appendChild(message_sendAlert);
content_sendAlert.appendChild(closeButton_sendAlert); content_sendAlert.appendChild(closeButton_sendAlert);
dialog_sendAlert.appendChild(content_sendAlert); dialog_sendAlert.appendChild(content_sendAlert);
window.document.body.appendChild(dialog_sendAlert); window.document.body.appendChild(dialog_sendAlert);
// Show the dialog // Show the dialog
dialog_sendAlert.showModal(); dialog_sendAlert.showModal();
// Close dialog on button click and remove elements from the DOM // Close dialog on button click and remove elements from the DOM
closeButton_sendAlert.onclick = () => { closeButton_sendAlert.onclick = () => {
dialog_sendAlert.close(); dialog_sendAlert.close();
dialog_sendAlert.addEventListener('close', () => { dialog_sendAlert.addEventListener('close', () => {
dialog_sendAlert.remove(); dialog_sendAlert.remove();
style.remove(); style.remove();
}); });
}; };
// CSS styles for Thunderbird with support for light and dark themes // CSS styles for Thunderbird with support for light and dark themes
const style = document.createElement('style'); const style = document.createElement('style');
style.textContent = ` style.textContent = `
.mzta_dialog { .mzta_dialog {
border: none; border: none;
border-radius: 8px; border-radius: 8px;
padding: 0; padding: 0;
width: 300px; width: 300px;
max-width: 90%; max-width: 90%;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
background-color: var(--dialog-bg-color, #fff); background-color: var(--dialog-bg-color, #fff);
color: var(--dialog-text-color, #000); color: var(--dialog-text-color, #000);
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
z-index: 1001; z-index: 1001;
} }
.mzta_dialog_content { .mzta_dialog_content {
position: relative; position: relative;
padding: 20px; padding: 20px;
} }
.mzta_dialog_close { .mzta_dialog_close {
position: absolute; position: absolute;
bottom: 10px; bottom: 10px;
right: 10px; right: 10px;
background: #007bff; background: #007bff;
border: none; border: none;
color: #ffffff; color: #ffffff;
font-size: 14px; font-size: 14px;
padding: 8px 12px; padding: 8px 12px;
cursor: pointer; cursor: pointer;
border-radius: 4px; border-radius: 4px;
} }
.mzta_dialog_close:hover { .mzta_dialog_close:hover {
background: #0056b3; background: #0056b3;
} }
.mzta_dialog_message { .mzta_dialog_message {
margin-bottom: 40px; margin-bottom: 40px;
font-size: 14px; font-size: 14px;
} }
/* Theme support */ /* Theme support */
:root { :root {
--dialog-bg-color: #ffffff; --dialog-bg-color: #ffffff;
--dialog-text-color: #000000; --dialog-text-color: #000000;
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
:root { :root {
--dialog-bg-color: #2e2e2e; --dialog-bg-color: #2e2e2e;
--dialog-text-color: #ffffff; --dialog-text-color: #ffffff;
} }
} }
/* Darker overlay for the page background */ /* Darker overlay for the page background */
.mzta_dialog_overlay { .mzta_dialog_overlay {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background: rgba(0, 0, 0, 0.7); background: rgba(0, 0, 0, 0.7);
z-index: 1000; z-index: 1000;
} }
`; `;
document.head.appendChild(style); document.head.appendChild(style);
}else{ }else{
alert(message.message); alert(message.message);