20 lines
594 B
JavaScript
20 lines
594 B
JavaScript
function escapeHtml(text) {
|
|
if (text == null) return '';
|
|
return text.toString()
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"');
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const logout = document.getElementById('logout-link');
|
|
if (logout) {
|
|
logout.addEventListener('click', async (e) => {
|
|
e.preventDefault();
|
|
await fetch('/api/auth/logout', { method: 'POST', credentials: 'include' });
|
|
window.location.href = '/login';
|
|
});
|
|
}
|
|
});
|