// noinspection JSUnresolvedVariable window.bannerFrench = false; function timeAgo(time) { if (!isNaN(parseInt(time))) { time = new Date(time).getTime(); } let periods = ["sec.", "mn.", "hr.", "d.", "wk.", "mo.", "y.", "ages"]; if (bannerFrench) { periods = ["sec.", "min.", "h.", "j.", "sem.", "mois", "an.", "des années"]; } 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]; if (bannerFrench) { return `${tense} ${difference} ${period}`; } else { return `${difference} ${period} ${tense}`; } } async function refreshBanner(_, french) { 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); } let active = 0; if (data['relations']['marefriends'] && data['relations']['marefriends'].length > 0) active++; if (data['relations']['caretakers'] && data['relations']['caretakers'].length > 0) active++; if (data['relations']['sexfriends'] && data['relations']['sexfriends'].length > 0) active++; if (data['relations']['sisters'] && data['relations']['sisters'].length > 0) active++; document.getElementById("member-banner").innerHTML = `

${data['id'] === "unknown" ? ` ${french ? "Membre inconnu" : "Unknown member"} (${data['system']['name']} System) ` : data['id'] === "fusion" ? (data['name'] === "fusion" ? ` ${french ? "Plusieurs membres fusionnés" : "Multiple merged members"} ` : data['name']) : data['name']}

${data['badges'].map(i => i.html).join(" ")} ${data['badges'].length === 0 ? " " : ""}
${french ? `Préfixe${data['prefixes'].length > 1 ? 's' : ''} ` : `Prefix${data['prefixes'].length > 1 ? 'es' : ''}`}:
${data['prefixes'].length > 0 && data['prefixes'][0] !== null ? `${data['prefixes'].join(', ')}` : `-`}
${french ? "" : ` ${french ? "Pronoms :" : "Pronouns:"}
${data['id'] === "fusion" ? "she/her" : data['pronouns']}
`} ${!data['median'] && data['id'] !== "unknown" ? ` ${data["id"] === "fusion" ? ` ${french ? "Fronte depuis " : "Fronting since"}:
${data['last_fronted'] ? ` ${data['last_fronted']['now'] ? ` ${data['last_fronted']['relative']}
  ` : ` ${french ? "Pas au front" : "Not fronting"}
  `} ` : `${french ? "Pas au front" : "Not fronting"}
 `}` : ` ${french ? "Front :" : "Last fronted:"}
${data['last_fronted'] ? ` ${data['last_fronted']['now'] ? ` ${french ? "En ce moment" : "Right now"}
(${french ? "commencé" : "started"} ${data['last_fronted']['relative']}) ` : ` ${data['last_fronted']['relative']}
(${french ? "pendant" : "for"} ${data['last_fronted']['duration']['pretty']}) `} ` : `${french ? "Jamais" : "Never"}
 `}`}
` : ''} ${data['id'] !== "fusion" ? ` ${data['id'] === "unknown" ? (french ? "Espèce : préférez demander" : "Species: best to ask") : ` ${french ? "Espèce :" : "Species:"} ${data['species'].filter(i => i && i['name'] !== "_").map(species => ` ${species['name']} `).join("")}`} ` : ''} ${data['id'] !== "fusion" ? ` ${french ? "Position :" : "Location:"} ${data['system']['page'] ? ` ${data['system']['name']}` : ` ${data['system']['name']}`} ${data['system']['subsystem'] ? `
${french ? "Sous-système :" : "Subsystem:"} ${data['system']['subsystem']['name']} ` : data['system']['temporary'] ? (french ? '
(temporaire)' : '
(temporary)') : ''}
` : ''}
${data['id'] !== "unknown" && data['id'] !== "fusion" ? `
${data['relations']['sexfriends'] && data['relations']['sexfriends'].length > 0 ? ` ${french ? (data['relations']['sexfriends'].length > 1 ? 'Rel. sexuelles ' : 'Rel. sexuelle ') : `Sexfriend${data['relations']['sexfriends'].length > 1 ? 's' : ''}`}: ${data['relations']['sexfriends'].length > 1 ? '
' : ''} ${data['relations']['sexfriends'].map(relation => ` `).join(``)} ${data['relations']['sexfriends'].length === 0 ? '-' : ''}
` : ``} ${data['relations']['marefriends'] && data['relations']['marefriends'].length > 0 ? ` ${french ? (data['relations']['marefriends'].length > 1 ? 'Copines ' : 'Copine ') : `Marefriend${data['relations']['marefriends'].length > 1 ? 's' : ''}`}: ${data['relations']['marefriends'].length > 1 ? '
' : ''} ${data['relations']['marefriends'].map(relation => ` `).join(``)} ${data['relations']['marefriends'].length === 0 ? '-' : ''}
` : ``} ${data['relations']['sisters'] && data['relations']['sisters'].length > 0 ? ` ${french ? (data['relations']['sisters'].length > 1 ? 'Sœurs ' : 'Sœur ') : `Sister${data['relations']['sisters'].length > 1 ? 's' : ''}`}: ${data['relations']['sisters'].length > 1 ? '
' : ''} ${data['relations']['sisters'].map(relation => ` `).join(``)} ${data['relations']['sisters'].length === 0 ? '-' : ''}
` : ``} ${data['relations']['caretakers'] && data['relations']['caretakers'].length > 0 ? ` ${french ? (data['relations']['caretakers'].length > 1 ? 'Gardiens ' : 'Gardien ') : `Caretaker${data['relations']['caretakers'].length > 1 ? 's' : ''}`}: ${data['relations']['caretakers'].length > 1 ? '
' : ''} ${data['relations']['caretakers'].map(relation => ` `).join(``)} ${data['relations']['caretakers'].length === 0 ? '-' : ''}
` : ''}
` : '
 
'}
`; }