27 lines
1012 B
JavaScript
27 lines
1012 B
JavaScript
// Load announcement content from the application info when the page loads
|
|
async function loadAnnouncement() {
|
|
try {
|
|
const announcementText = await window.electronAPI.readAnnouncement();
|
|
const announcementContent = document.getElementById('announcement-content');
|
|
if (announcementContent && announcementText) {
|
|
announcementContent.innerHTML = formatTextForHtml(announcementText);
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to load announcement:', error);
|
|
document.getElementById('announcement-content').textContent = 'Failed to load announcement.';
|
|
}
|
|
}
|
|
|
|
function formatTextForHtml(text) {
|
|
let formattedText = text.replace(/\n/g, '<br>');
|
|
formattedText = formattedText.replace(/\t/g, ' ');
|
|
formattedText = formattedText.replace(/ /g, ' ');
|
|
|
|
return formattedText;
|
|
}
|
|
|
|
// Close the window when the close button is clicked
|
|
function closeWindow() {
|
|
window.electronAPI.closeAnnouncementWindow();
|
|
}
|