// noinspection JSUnresolvedVariable function timeAgo(time) { if (!isNaN(parseInt(time))) { time = new Date(time).getTime(); } let periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"]; 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 (difference <= 10 && difference >= 0) { return tense = "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" : ''); return `${difference} ${period} ${tense}`; } async function refreshBanner(offline) { if (!offline) offline = false; 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('
, ')}
Pronouns:
${data['pronouns']}
${!data['median'] ? `
Last fronted:
${data['last_fronted'] ? `
${data['last_fronted']['now'] ? `
Right now