Test JS
This commit is contained in:
parent
c4c9e021e4
commit
fd8e5e9ebe
@ -1,4 +1,5 @@
|
|||||||
let UserInfo = {};
|
let UserInfo = {};
|
||||||
|
|
||||||
async function handleResponse(data, successMessage, failureMessage) {
|
async function handleResponse(data, successMessage, failureMessage) {
|
||||||
const statusMessageContainer = document.getElementById("statusMessageContainer");
|
const statusMessageContainer = document.getElementById("statusMessageContainer");
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ async function handlePageResponse(data) {
|
|||||||
|
|
||||||
if (data.Page) {
|
if (data.Page) {
|
||||||
pageArea.innerHTML = data.Page;
|
pageArea.innerHTML = data.Page;
|
||||||
if(data.PageLocation){
|
if (data.PageLocation) {
|
||||||
history.pushState({}, "", data.PageLocation);
|
history.pushState({}, "", data.PageLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +135,7 @@ async function doPageAction(requestData, wantsReturn = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initAjaxNavigationEvents(){
|
async function initAjaxNavigationEvents() {
|
||||||
const allLinks = document.querySelectorAll('.navsite_link, .navpage_link');
|
const allLinks = document.querySelectorAll('.navsite_link, .navpage_link');
|
||||||
const pageLinks = document.querySelectorAll('.navpage_link');
|
const pageLinks = document.querySelectorAll('.navpage_link');
|
||||||
|
|
||||||
@ -168,25 +169,25 @@ async function initAjax() {
|
|||||||
await onPageLoad();
|
await onPageLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPageLoad(){
|
async function onPageLoad() {
|
||||||
await restoreUserInfo();
|
await restoreUserInfo();
|
||||||
let currentSite = localStorage.getItem("currentSite");
|
let currentSite = localStorage.getItem("currentSite");
|
||||||
let currentPage = localStorage.getItem("currentPage");
|
let currentPage = localStorage.getItem("currentPage");
|
||||||
if(currentSite === "home" && currentPage === "settings"){
|
if (currentSite === "home" && currentPage === "settings") {
|
||||||
if(document.getElementById("user-settings")){
|
if (document.getElementById("user-settings")) {
|
||||||
await populateUserInfoFields(UserInfo);
|
await populateUserInfoFields(UserInfo);
|
||||||
}
|
}
|
||||||
if(document.getElementById("admin-settings")){
|
if (document.getElementById("admin-settings")) {
|
||||||
await listActivationCodes(true);
|
await listActivationCodes(true);
|
||||||
await listUsers(true);
|
await listUsers(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(currentSite === "home" && currentPage === "account") {
|
if (currentSite === "home" && currentPage === "account") {
|
||||||
await showDashboardGreeting();
|
await showDashboardGreeting();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function navigateTo(site, page){
|
async function navigateTo(site, page) {
|
||||||
const data = {
|
const data = {
|
||||||
action: "getPage",
|
action: "getPage",
|
||||||
site: site,
|
site: site,
|
||||||
@ -199,14 +200,14 @@ async function navigateTo(site, page){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function softReload(){
|
async function softReload() {
|
||||||
let currentSite = localStorage.getItem("currentSite");
|
let currentSite = localStorage.getItem("currentSite");
|
||||||
let currentPage = localStorage.getItem("currentPage");
|
let currentPage = localStorage.getItem("currentPage");
|
||||||
await navigateTo(currentSite, currentPage);
|
await navigateTo(currentSite, currentPage);
|
||||||
umami.track("softReload");
|
umami.track("softReload");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshNavbar(){
|
async function refreshNavbar() {
|
||||||
const data = {
|
const data = {
|
||||||
action: "getNavigation",
|
action: "getNavigation",
|
||||||
};
|
};
|
||||||
@ -334,10 +335,10 @@ async function populateUserInfoFields(userData) {
|
|||||||
document.getElementById("updateNewEmail").value = userData.Email || "";
|
document.getElementById("updateNewEmail").value = userData.Email || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restoreUserInfo(){
|
async function restoreUserInfo() {
|
||||||
for (let i = 0; i < localStorage.length; i++) {
|
for (let i = 0; i < localStorage.length; i++) {
|
||||||
let key = localStorage.key(i);
|
let key = localStorage.key(i);
|
||||||
if (key.startsWith("UserInfo_")){
|
if (key.startsWith("UserInfo_")) {
|
||||||
let keyClean = key.replace("UserInfo_", "");
|
let keyClean = key.replace("UserInfo_", "");
|
||||||
UserInfo[keyClean] = localStorage.getItem(key);
|
UserInfo[keyClean] = localStorage.getItem(key);
|
||||||
}
|
}
|
||||||
@ -348,15 +349,15 @@ async function getUserInfo() {
|
|||||||
const data = {
|
const data = {
|
||||||
action: "get_user_info",
|
action: "get_user_info",
|
||||||
};
|
};
|
||||||
|
const result = await doAction('/account', data, "User info retrieved Successfully!", "User info retrieval failed.", true);
|
||||||
|
|
||||||
|
if (result && result.Status === "Success") {
|
||||||
|
result.UserInfo.forEach((value, index) => {
|
||||||
|
localStorage.setItem("UserInfo_" + index, value);
|
||||||
|
UserInfo[index] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
doAction('/account', data, "User info retrieved Successfully!", "User info retrieval failed.", true) .then((result) => {
|
|
||||||
if (result && result.Status === "Success") {
|
|
||||||
result.UserInfo.forEach(function callback(value, index) {
|
|
||||||
localStorage.setItem("UserInfo_" + index, value);
|
|
||||||
UserInfo[index] = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//User settings end
|
//User settings end
|
||||||
@ -377,7 +378,7 @@ async function addActivationCodes() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listUsers(silent=false) {
|
async function listUsers(silent = false) {
|
||||||
const data = {
|
const data = {
|
||||||
action: "list_users",
|
action: "list_users",
|
||||||
};
|
};
|
||||||
@ -390,7 +391,7 @@ async function listUsers(silent=false) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listActivationCodes(silent=false) {
|
async function listActivationCodes(silent = false) {
|
||||||
const data = {
|
const data = {
|
||||||
action: "list_activation_codes",
|
action: "list_activation_codes",
|
||||||
};
|
};
|
||||||
@ -421,6 +422,7 @@ async function deleteActivationCode(activationCode) {
|
|||||||
await listActivationCodes();
|
await listActivationCodes();
|
||||||
umami.track("deleteActivationCode");
|
umami.track("deleteActivationCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Admin settings end
|
//Admin settings end
|
||||||
|
|
||||||
if (document.readyState !== "loading") {
|
if (document.readyState !== "loading") {
|
||||||
|
Loading…
Reference in New Issue
Block a user