Files
Kendrick Bollens 3906c33967 Initial commit: Templates Reply Add-on für Hotel Park Soltau
Modifiziertes Templates Reply Thunderbird Add-on mit:
- HTML-Import von Netzlaufwerk
- Massen-Delete mit Checkboxen
- Deutsches UI mit "Vorlagen" Button
- 16 Hotel-Vorlagen als HTML-Dateien
2026-04-09 00:37:18 +02:00

67 lines
2.1 KiB
JavaScript

// popup.js
const TEMPLATE_STORAGE_KEY = 'message_templates';
async function getTemplates() {
try {
const result = await browser.storage.local.get(TEMPLATE_STORAGE_KEY);
return result[TEMPLATE_STORAGE_KEY] || [];
} catch (error) {
console.error("Error retrieving templates in popup:", error);
return [];
}
}
function insertTemplateAndClose(templateText) {
browser.runtime.sendMessage({
action: 'insertTemplate',
text: templateText
}).catch(e => console.error("Error sending message to background:", e));
window.close();
}
async function renderPopupButtons() {
const templates = await getTemplates();
const templateList = document.getElementById('template-list');
templateList.innerHTML = '';
if (templates.length === 0) {
templateList.innerHTML = `
<div class="empty-state">
Keine Vorlagen vorhanden.<br>
<a href="#" id="open-options">Jetzt einrichten</a>
</div>`;
document.getElementById('open-options').addEventListener('click', (e) => {
e.preventDefault();
browser.runtime.openOptionsPage();
window.close();
});
return;
}
templates.forEach(template => {
const button = document.createElement('button');
button.textContent = template.name;
button.addEventListener('click', () => {
insertTemplateAndClose(template.content);
});
templateList.appendChild(button);
});
// Footer with manage link
const footer = document.createElement('div');
footer.className = 'footer';
const manageLink = document.createElement('a');
manageLink.href = "#";
manageLink.textContent = 'Vorlagen verwalten';
manageLink.addEventListener('click', (e) => {
e.preventDefault();
browser.runtime.openOptionsPage();
window.close();
});
footer.appendChild(manageLink);
templateList.parentNode.appendChild(footer);
}
document.addEventListener('DOMContentLoaded', renderPopupButtons);