i have this functions
I need them to work when the buttons are clicked
async function Ghash(name){
let res = await fetch(`https://account.imperiomc.click/${name}.json?`+new Date().getTime()), json = await res.json(), hash, skin;
if (json.skins.slim != null){
hash = await json.skins.slim
skin = "Alex"
} else {
hash = await json.skins.default
skin = "Steve"
}
console.log("Skin model is "+skin)
return hash
}
function populateAuthAccounts(){
const authAccounts = ConfigManager.getAuthAccounts()
const authKeys = Object.keys(authAccounts)
if(authKeys.length === 0){
return
}
const selectedUUID = ConfigManager.getSelectedAccount().uuid
let authAccountStr = ''
authKeys.map((val) => {
const acc = authAccounts[val]
const hash = Ghash(acc.displayName)
.then(function(hash) {
const settingsCurrentAccounts = document.getElementById('settingsCurrentAccounts')
let url = `https://account.imperiomc.click/preview/hash/${hash}?`+new Date().getTime();
authAccountStr += `<div class="settingsAuthAccount" uuid="${acc.uuid}">
<div class="settingsAuthAccountLeft">
<img class="settingsAuthAccountImage" alt="${acc.displayName}" src="${url}">
</div>
//[...]cropped code
<div class="settingsAuthAccountActions">
<button class="settingsAuthAccountSelect" ${selectedUUID === acc.uuid ? 'selected>Selected Account ✔' : '>Select Account'}</button>
<div class="settingsAuthAccountWrapper">
<button class="settingsAuthAccountLogOut">Log Out</button>
</div>
</div>
</div>
</div>`
settingsCurrentAccounts.innerHTML = authAccountStr
})
})
}
if the html code is outside the .then the function const hash = ghash(acc.displayName)
does not return what I want
And if the code is inside the .then the buttons are invalid