fix things, speed things up a little (scuffed)

This commit is contained in:
quoije
2025-02-05 19:22:07 -05:00
parent bcafaf8a56
commit 0c1f148fe5
13 changed files with 563 additions and 554 deletions
+1 -48
View File
@@ -74,54 +74,7 @@
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Check if the user is already logged in by looking for auth_token in localStorage
if (localStorage.getItem('auth_token')) {
// If the token is found, redirect to /movies.html
window.location.href = '/movies.html';
}
// Handle login form submission
document.getElementById('login-form').addEventListener('submit', async function (e) {
e.preventDefault();
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const res = await fetch('/api/users/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
if (res.ok) {
const data = await res.json();
// Save the token to localStorage
localStorage.setItem('auth_token', data.token);
window.location.href = '/movies.html'; // Redirect to movies page on success
} else {
const error = await res.json();
alert(`${error.message}`);
}
});
// Fetch version information from the API
async function fetchVersionInfo() {
const res = await fetch('/api/users/version');
if (res.ok) {
const data = await res.json();
// Update footer with the fetched version info
const footerText = `${data.date} - ${data.version} - ${data.message}`;
document.getElementById('footer-text').textContent = footerText;
} else {
document.getElementById('footer-text').textContent = '';
}
}
// Call the function to fetch and display the version info
// Doesn't work on prod, will fix later
fetchVersionInfo();
</script>
<script src="./js/app_index.js"></script>
</body>
</html>