mirror of
https://dev.s-ul.net/Galexion/MaiMaiDXNet.git
synced 2024-12-03 21:17:17 +01:00
102 lines
5.0 KiB
Plaintext
102 lines
5.0 KiB
Plaintext
<% var rootPath='../' ; %>
|
|
<%- include(rootPath + 'templates/header.ejs' ); %>
|
|
<% function normalizeText(text) { return text .normalize('NFD') .replace(/[\u0300-\u036f]/g, '' )
|
|
.replace(/[\uFF01-\uFF5E]/g, function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xFEE0); }); } %>
|
|
<link href="/stylesheets/user.css" rel="stylesheet" type="text/css">
|
|
<div id="User">
|
|
<h1>Yo! Welcome Back <%= normalizeText(userdata.user_name) %>!</h1>
|
|
<button id="clear-storage-btn">Sign Out</button>
|
|
|
|
<script>
|
|
const extId = localStorage.getItem('ext_id');
|
|
const luid = localStorage.getItem('luid');
|
|
const clearStorageBtn = document.getElementById('clear-storage-btn');
|
|
clearStorageBtn.addEventListener('click', () => {
|
|
// Remove the cookies
|
|
function removeCookies() {
|
|
// Set the expiration date to a date in the past
|
|
const expirationDate = new Date(0).toUTCString();
|
|
|
|
// Set the ext_id cookie to expire
|
|
document.cookie = `ext_id=; expires=${expirationDate}`;
|
|
|
|
// Set the luid cookie to expire
|
|
document.cookie = `luid=; expires=${expirationDate}`;
|
|
|
|
// Set the aime_card_id cookie to expire
|
|
document.cookie = `aime_card_id=; expires=${expirationDate}`;
|
|
}
|
|
|
|
// Example usage
|
|
removeCookies();
|
|
|
|
console.log('Local storage cleared.');
|
|
window.location = "/";
|
|
});
|
|
|
|
// Get the cookie string
|
|
const cookieString = document.cookie;
|
|
|
|
// Parse the cookie string and extract the values
|
|
const cookies = cookieString.split(';');
|
|
let ext_id2, luid2;
|
|
|
|
for (let i = 0; i < cookies.length; i++) {
|
|
const cookie = cookies[i].trim();
|
|
const cookieParts = cookie.split('=');
|
|
|
|
if (cookieParts[0] === 'ext_id') {
|
|
ext_id2 = cookieParts[1];
|
|
}
|
|
|
|
if (cookieParts[0] === 'luid') {
|
|
luid2 = cookieParts[1];
|
|
}
|
|
}
|
|
|
|
// Sends user to the sign in page if they aren't already signed in to the website.
|
|
if (ext_id2 && luid2) {
|
|
console.log(`ext_id: ${ext_id2}, luid: ${luid2}`);
|
|
|
|
} else {
|
|
console.log('User Data Not Detected! Please Sign In.');
|
|
window.location = "/";
|
|
}
|
|
</script>
|
|
|
|
<% if(userdata.icon_id===10) { %> <!-- If the user icon id is set to 10, it's a custom image and you need to grab the image that the user uploaded. -->
|
|
<img id="user-image" src="" alt="User Image">
|
|
|
|
<script>
|
|
const userImage = document.getElementById('user-image');
|
|
userImage.src = "images/" + ext_id2 + '-up.jpg';
|
|
</script>
|
|
|
|
<% } else {%> <!-- If Not, use the userdata.icon_id variable to find which icon you need. -->
|
|
<img id="user-image" src="" alt="User Image">
|
|
|
|
<script data-userdata="<%=JSON.stringify(userdata)%>">
|
|
const userdata = JSON.parse(document.currentScript.getAttribute('data-userdata'));
|
|
const userImage = document.getElementById('user-image');
|
|
const UI_Icon = userdata.icon_id
|
|
function padNumber(num, size) { // pad the number because haha game weird
|
|
var s = num + "";
|
|
while (s.length < size) s = "0" + s;
|
|
return s;
|
|
}
|
|
|
|
// Usage:
|
|
userImage.src = "assets/icon/UI_Icon_" + padNumber(Number(UI_Icon),6) + '.png';
|
|
</script>
|
|
<%}%>
|
|
|
|
<details>
|
|
<summary>Developer Only Information</summary>
|
|
For Development purposes only, send statistics found in this menu when encontering UI
|
|
Errors.
|
|
<details>
|
|
<summary>Raw User Details</summary>
|
|
<pre><code><%=JSON.stringify(userdata, null, 2)%></code></pre>
|
|
</details>
|
|
</details>
|
|
</div> |