speakmore-2.0/templates/head.html
2024-09-10 11:53:00 +02:00

46 lines
2.2 KiB
HTML

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %}</title>
<script src="https://cdn.jsdelivr.net/npm/markdown-it/dist/markdown-it.min.js"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='output.css') }}">
<script src="{{ url_for('static', filename='js/notification.js') }}"></script>
<script src="{{ url_for('static', filename='js/common.js') }}"></script>
<script src="{{ url_for('static', filename='js/upload_handler.js') }}"></script>
<script src="https://cdn.socket.io/4.0.1/socket.io.min.js"></script>
<script src="https://vjs.zencdn.net/7.11.4/video.min.js"></script>
<script src="https://kit.fontawesome.com/47dbf3c43e.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<input type="hidden" id="current-chat-user-id" value="{{ friend.id if friend else '' }}">
<input type="hidden" id="current-group-id" value="{{ group.id if group else '' }}">
<script>
// Function to apply the theme based on user selection or system preference
function applyTheme(theme) {
const root = document.documentElement;
if (theme === 'dark' || (theme === 'automatic' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
root.classList.add('dark');
} else {
root.classList.remove('dark');
}
}
// Apply the theme on page load based on the current theme setting
document.addEventListener('DOMContentLoaded', (event) => {
const currentTheme = localStorage.getItem('theme') || 'automatic';
applyTheme(currentTheme);
// Listen for changes to the system theme and apply if the user selected 'automatic'
if (currentTheme === 'automatic') {
window.matchMedia('(prefers-color-scheme: dark)').addListener(e => {
applyTheme('automatic');
});
}
});
</script>
{% if 'username' in session %}
<style>
{{ current_user.custom_css | safe }}
</style>
{% endif %}