diff --git a/equipment/equipment.js b/equipment/equipment.js index 2ccc386..031da5f 100644 --- a/equipment/equipment.js +++ b/equipment/equipment.js @@ -1,25 +1,68 @@ fetch("../header.html") -.then(res => res.text()) -.then(html => { -const headerContainer = document.getElementById("header-container"); -headerContainer.innerHTML = html; + .then(res => res.text()) + .then(html => { + const headerContainer = document.getElementById("header-container"); + if (headerContainer) { + headerContainer.innerHTML = html; + } -const logoutForm = document.getElementById("logout-form"); -if (logoutForm && typeof CONFIG !== 'undefined') { - const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); - logoutForm.action = apiBase + "/api/v1/spfn/logout"; - - const originInput = document.getElementById("logout_frontend_origin"); - if (originInput) { - originInput.value = window.location.origin; - } -} + if (typeof CONFIG !== 'undefined') { + const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); -const friendButton = headerContainer.querySelector('.menu-item.equipment'); -if (friendButton) { -friendButton.classList.add('active'); -} - -// temporaily force hide lol -document.getElementById("loading-overlay").style.display = "none"; -}); \ No newline at end of file + const logoutForm = document.getElementById("logout-form"); + if (logoutForm) { + logoutForm.action = apiBase + "/api/v1/spfn/logout"; + const originInput = document.getElementById("logout_frontend_origin"); + if (originInput) originInput.value = window.location.origin; + } + + fetch(apiBase + "/api/v1/me", { credentials: 'include' }) + .then(res => { + if (!res.ok) throw new Error("Status: " + res.status); + return res.json(); + }) + .then(data => { + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { + console.error("Failed to parse inner JSON:", e); + } + } + + const nameEl = document.getElementById('mii-name'); + const imgEl = document.getElementById('mii-img'); + + if (nameEl) { + const displayName = + (data.mii && data.mii.name) || + data.nickname || + data.user_id || + data.username || + "User"; + + nameEl.textContent = displayName; + } + + if (imgEl) { + const miiBlob = (data.mii && data.mii.data) || data.mii_data; + if (miiBlob) { + const encodedData = encodeURIComponent(miiBlob); + imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodedData}&type=face&width=270`; + imgEl.style.display = 'block'; + } + } + }) + .catch(err => { + const nameEl = document.getElementById('mii-name'); + if (nameEl) nameEl.textContent = "Guest"; + console.error("Profile Error:", err); + }); + } + + const friendButton = document.querySelector('.menu-item.equipment'); + if (friendButton) friendButton.classList.add('active'); + + const overlay = document.getElementById("loading-overlay"); + if (overlay) overlay.style.display = "none"; + }); \ No newline at end of file diff --git a/friend_list/friendlist.js b/friend_list/friendlist.js index ee2e671..c25e952 100644 --- a/friend_list/friendlist.js +++ b/friend_list/friendlist.js @@ -1,19 +1,64 @@ fetch("../header.html") -.then(res => res.text()) -.then(html => { -const headerContainer = document.getElementById("header-container"); -headerContainer.innerHTML = html; + .then(res => res.text()) + .then(html => { + const headerContainer = document.getElementById("header-container"); + if (headerContainer) { + headerContainer.innerHTML = html; + } -const logoutForm = document.getElementById("logout-form"); -if (logoutForm && typeof CONFIG !== 'undefined') { - const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); - logoutForm.action = apiBase + "/api/v1/spfn/logout"; - - const originInput = document.getElementById("logout_frontend_origin"); - if (originInput) { - originInput.value = window.location.origin; - } -} + if (typeof CONFIG !== 'undefined') { + const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, ""); + + const logoutForm = document.getElementById("logout-form"); + if (logoutForm) { + logoutForm.action = apiBase + "/api/v1/spfn/logout"; + const originInput = document.getElementById("logout_frontend_origin"); + if (originInput) originInput.value = window.location.origin; + } + + fetch(apiBase + "/api/v1/me", { credentials: 'include' }) + .then(res => { + if (!res.ok) throw new Error("Status: " + res.status); + return res.json(); + }) + .then(data => { + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { + console.error("Failed to parse inner JSON:", e); + } + } + + const nameEl = document.getElementById('mii-name'); + const imgEl = document.getElementById('mii-img'); + + if (nameEl) { + const displayName = + (data.mii && data.mii.name) || + data.nickname || + data.user_id || + data.username || + "User"; + + nameEl.textContent = displayName; + } + + if (imgEl) { + const miiBlob = (data.mii && data.mii.data) || data.mii_data; + if (miiBlob) { + const encodedData = encodeURIComponent(miiBlob); + imgEl.src = `https://mii-unsecure.ariankordi.net/miis/image.png?erri=s6u7r-rsp&data=${encodedData}&type=face&width=270`; + imgEl.style.display = 'block'; + } + } + }) + .catch(err => { + const nameEl = document.getElementById('mii-name'); + if (nameEl) nameEl.textContent = "Guest"; + console.error("Profile Error:", err); + }); + } const friendButton = headerContainer.querySelector('.menu-item.friend'); if (friendButton) { diff --git a/header.html b/header.html index 95e24a6..15dcae7 100644 --- a/header.html +++ b/header.html @@ -56,6 +56,11 @@
+
+ +
+ Loading... +
- + }) + .catch(err => console.error("Failed to load header:", err)); + diff --git a/style.css b/style.css index 41513c6..7b41509 100644 --- a/style.css +++ b/style.css @@ -135,8 +135,7 @@ body { z-index: 2; } -.twitterbgbox::before { - content: ""; +.mii-icon-container { position: absolute; width: 60px; height: 60px; @@ -144,11 +143,36 @@ body { left: -20px; background-color: white; border-radius: 50%; - z-index: 2; + z-index: 3; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; + border: 4px solid #333333; /* tickles my brain but might remove for original look */ } -.twitterbgbox::after { - content: "WWWWWWWWWWWW"; +#mii-img { + width: 110%; + height: auto; + display: none; +} + +.twitterbgbox::before { + display: none; +} + +.profile-name-label { + position: absolute; + top: 14px; + left: 55px; + color: white; + font-family: 'RegularFont', sans-serif; + font-weight: normal; + font-size: 18px; + z-index: 1; +} + +.profile-name-label { position: absolute; top: 12px; left: 48px;