Added almost all features except language, ads, seo, pages
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
if (window.Livewire && typeof window.Livewire.dispatch === 'function') {
|
||||
setTimeout(() => {
|
||||
Livewire.dispatch('getEmail');
|
||||
}, 2000);
|
||||
|
||||
document.addEventListener('closeModal', () => {
|
||||
document.querySelectorAll('dialog[data-modal]').forEach(dialog => {
|
||||
if (typeof dialog.close === 'function') {
|
||||
dialog.close();
|
||||
console.log(`Closed dialog with data-modal="${dialog.getAttribute('data-modal')}"`);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -55,15 +50,81 @@ toast.remove();
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
function handleDispatches(dispatches) {
|
||||
dispatches.forEach(dispatch => {
|
||||
if (dispatch.name === "showAlert") {
|
||||
const params = dispatch.params[0];
|
||||
showToast(params);
|
||||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener("showAlert", (event) => {
|
||||
const detail = event.detail[0];
|
||||
showToast(detail);
|
||||
});
|
||||
|
||||
window.addEventListener("copyEmail", (event) => {
|
||||
const element = document.getElementById("copyEmail");
|
||||
if (element) {
|
||||
const textToCopy = element.innerHTML;
|
||||
navigator.clipboard.writeText(textToCopy).then(() => {
|
||||
const detail = { type: 'success', message: 'Email copied to clipboard' };
|
||||
showToast(detail);
|
||||
}).catch(err => {
|
||||
const detail = { type: 'error', message: 'Failed to copy email' };
|
||||
showToast(detail);
|
||||
console.error('Copy failed:', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("downloadFile", function (event) {
|
||||
const downloadId = event.detail?.download_id;
|
||||
if (!downloadId) return;
|
||||
|
||||
const messageContainer = document.querySelector(`#message-${downloadId}`);
|
||||
if (!messageContainer) return;
|
||||
|
||||
const textarea = messageContainer.querySelector("textarea");
|
||||
if (!textarea) return;
|
||||
|
||||
const content = textarea.value;
|
||||
const blob = new Blob([content], { type: "message/rfc822" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = `email-${downloadId}.eml`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
setTimeout(() => {
|
||||
link.remove();
|
||||
URL.revokeObjectURL(url);
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
window.addEventListener("printFile", function (event) {
|
||||
const printId = event.detail?.print_id;
|
||||
if (!printId) return;
|
||||
|
||||
const messageContainer = document.querySelector(`#message-${printId}`);
|
||||
if (!messageContainer) return;
|
||||
|
||||
const textarea = messageContainer.querySelector("textarea");
|
||||
if (!textarea) return;
|
||||
|
||||
const content = textarea.value;
|
||||
|
||||
const printWindow = window.open('', '', 'width=800,height=600');
|
||||
if (!printWindow) return;
|
||||
|
||||
printWindow.document.write(`
|
||||
<html>
|
||||
<head>
|
||||
<title>Email Print</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; padding: 20px; white-space: pre-wrap; }
|
||||
</style>
|
||||
</head>
|
||||
<body>${content.replace(/\n/g, '<br>')}</body>
|
||||
</html>
|
||||
`);
|
||||
|
||||
printWindow.document.close();
|
||||
printWindow.focus();
|
||||
printWindow.print();
|
||||
printWindow.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user