1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-11-24 06:30:12 +01:00
MaiMaiDXNet/views/index.ejs
2023-02-16 18:50:32 -05:00

60 lines
2.5 KiB
Plaintext

<% var rootPath='../' ; %>
<%- include(rootPath + 'templates/header.ejs' ); %>
<div id="wrapper">
<img src="MaiMaiDXNet/maimaidxex.jpg">
</div>
<div id="loginContent">
<h1>MaiMaiDX.Net</h1>
<h5>Total Users Registered: <%= params.totalUsers %>
</h5>
<h4>Please Input your 20 Digit Access Code.</h4>
<form id="myForm">
<input type="text" name="myInput" maxlength="20" placeholder="0000011111222223333344444" required>
<button type="submit">Submit</button>
</form>
<script>
const extId = localStorage.getItem('ext_id');
const luid = localStorage.getItem('luid');
if (extId === null || luid === null) {
console.log('User Data Not Detected! Please Sign In.');
} else {
console.log(`User Data Found! Redirecting to User Page.`);
window.location = "/user";
}
const form = document.getElementById("myForm");
form.addEventListener("submit", function (event) {
event.preventDefault(); // Prevent the default form submission behavior
const input = document.getElementsByName("myInput")[0].value;
const url = "/api/getExtId"; // Replace with your API endpoint URL
// Send the input data to the API endpoint using fetch
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ input: input })
})
.then(response => response.json())
.then(data => {
console.log(data)
let releventData = { luid: data.data.luid, ext_id: data.data.ext_id }
console.log(releventData)
// Save data to local storage
localStorage.setItem('ext_id', data.data.ext_id);
localStorage.setItem('luid', data.data.luid);
window.location = "/user";
})
.catch(error => console.error(error));
});
</script> <!-- ToDo: Move this script to a seperate JS file.-->
</div>
</body>
</html>