// noinspection JSUnresolvedVariable window.bannerFrench = false; function timeAgo(time) { if (!isNaN(parseInt(time))) { time = new Date(time).getTime(); } let periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; if (bannerFrench) { periods = ["seconde", "minute", "heure", "jour", "semaine", "mois", "an", "des année"]; } let lengths = ["60", "60", "24", "7", "4.35", "12", "100"]; let now = new Date().getTime(); let difference = Math.round((now - time) / 1000); let tense; let period; if (bannerFrench) { if (difference <= 10 && difference >= 0) { return "à l'instant"; } else if (difference > 0) { tense = "il y a"; } else { tense = "dans"; } } else { if (difference <= 10 && difference >= 0) { return "now"; } else if (difference > 0) { tense = "ago"; } else { tense = "later"; } } let j; for (j = 0; difference >= lengths[j] && j < lengths.length - 1; j++) { difference /= lengths[j]; } difference = Math.round(difference); period = periods[j] + (difference > 1 ? "s" : ''); if (bannerFrench) { return `${tense} ${difference} ${period}`; } else { return `${difference} ${period} ${tense}`; } } async function refreshBanner(offline, french) { if (!offline) offline = false; if (!french) french = false; window.bannerFrench = french; let data = window.currentMemberData; let index; if (data['last_fronted'] && data['last_fronted']['timestamp']) { data['last_fronted']['relative'] = timeAgo(currentMemberData.last_fronted.timestamp * 1000); } if (data.id === "scootaloo" && new Date().getDay() % 2 === 0) { data['relations']['marefriends'] = data['relations']['marefriends'].reverse(); } if (offline) { let images = JSON.parse(await localforage.getItem("images")); index = 0; for (let species of data['species']) { data['species'][index]["icon_offline"] = images.misc.species[species['id']]; index++; } index = 0; for (let relation of data['relations']['marefriends']) { data['relations']['marefriends'][index]["icon_offline"] = images.ponytown[relation['id'].split("/")[0]][relation['id'].split("/")[1]]; index++; } index = 0; for (let relation of data['relations']['sisters']) { data['relations']['sisters'][index]["icon_offline"] = images.ponytown[relation['id'].split("/")[0]][relation['id'].split("/")[1]]; index++; } if (data['relations']['caretakers']) { index = 0; for (let relation of data['relations']['caretakers']) { data['relations']['caretakers'][index]["icon_offline"] = images.ponytown[relation['id'].split("/")[0]][relation['id'].split("/")[1]]; index++; } } data['system']['icon_offline'] = images.misc.systems[data['system']['icon']]; } document.getElementById("member-banner").innerHTML = `
${data['prefixes'].join('
, ')}
${french ? "Pronoms :" : "Pronouns:"}
${data['id'] === "fusion" ? "she/her" : data['pronouns']}
${!data['median'] && data['id'] !== "unknown" ? `
${data["id"] === "fusion" ? `
Fronting since :
${data['last_fronted'] ? `
${data['last_fronted']['now'] ? `
${data['last_fronted']['relative']}