From c4a9dd9593747e025bfc579eda8b138475100133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Sun, 4 Feb 2024 09:19:35 +0100 Subject: [PATCH] autoload user info --- lib/page.php | 5 ++++- templates/skeleton.html | 4 +--- templates/userActions.html | 17 +++++++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/page.php b/lib/page.php index 9362ebd..1a1515d 100644 --- a/lib/page.php +++ b/lib/page.php @@ -112,9 +112,12 @@ function getPage($page_name = null): array|false|string $page_title = $page_name; } + $dynastyle = ""; $navpages = generateNavigation(); diff --git a/templates/skeleton.html b/templates/skeleton.html index a1f97c1..0e5fa14 100644 --- a/templates/skeleton.html +++ b/templates/skeleton.html @@ -8,9 +8,7 @@ Adlerka __TEMPLATE_PAGE_TITLE__ - + __TEMPLATE__DYNASTYLE__ __TEMPLATE__NAV__ diff --git a/templates/userActions.html b/templates/userActions.html index 93049af..70b3ee4 100644 --- a/templates/userActions.html +++ b/templates/userActions.html @@ -41,17 +41,29 @@ doAccountAction(data, "Email update Successful!", "Email update failed."); } + function populateUserInfoFields(userData) { + document.getElementById("updateFirstName").value = userData.first_name || ""; + document.getElementById("updateLastName").value = userData.last_name || ""; + document.getElementById("updateNickname").value = userData.nickname || ""; + document.getElementById("updateMinecraftNick").value = userData.minecraft_nick || ""; + document.getElementById("updateNewEmail").value = userData.Email || ""; + } + async function getUserInfo() { const data = new URLSearchParams(); data.append("action", "get_user_info"); - const result = await doAccountAction(data, "User info retrieved Successfully!", "User info retrieval failed."); + const result = await doAccountAction(data, "User info retrieved Successfully!", "User info retrieval failed.", true); if (result && result.Status === "Success") { - displayUserInfo(result.UserInfo); + populateUserInfoFields(result.UserInfo); } } + function init(){ + getUserInfo(); + } + function displayUserInfo(userData) { const tableContainer = document.getElementById("userInfoTable"); tableContainer.innerHTML = ""; // Clear previous content @@ -75,6 +87,7 @@ tableContainer.appendChild(table); } + window.onload = init();