// noinspection JSUnresolvedVariable
window.bannerFrench = false;
function timeAgo(time) {
if (!isNaN(parseInt(time))) {
time = new Date(time).getTime();
}
let periods = ["sec", "min", "hr", "d", "wk", "mo", "y", "ages"];
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 "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];
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++;
if (data['relations']['friends'] && data['relations']['friends'].length > 0) active++;
document.getElementById("member-banner").innerHTML = `
${data['id'] === "unknown" ? `
${french ? "Membre inconnu" : "Unknown member"} (${data['system']['name']})
` : data['id'] === "fusion" ? (data['name'] === "fusion" ? `
${french ? "Plusieurs membres fusionnés" : "Multiple merged members"}
` : data['name']) : data['name']}
${data['species'].filter(i => i && i['name'] !== "_").map(species => `
`).join("")}
${data['badges'].map(i => i.html).join(" ")}
${data['badges'].length === 0 ? " " : ""}
${french ? "" : `
${data['id'] === "fusion" ? "she/her" : data['pronouns']}${data['age'] !== "-" ? '
' + data['age'] : ''}
`}
${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('
, ')}
` : `-`}
${!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['gender'] !== null ? `
${data['id'] === "unknown" ? (french ? "Genre :
préférez demander" : "Gender:
best to ask") : `
${french ? "Genre :" : "Gender:"}
${data['gender']}`}
` : ''}
${data['id'] !== "fusion" ? `
${french ? "Position :" : "Location:"}
${data['system']['page'] ? ` ${data['system']['name']}` : ` ${data['system']['name']}`}
${data['species'].filter(i => i && i['name'] !== "_").map(species => `
`).join("")}
` : ''}
${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 ? '-' : ''}
` : ''}
${data['relations']['friends'] && data['relations']['friends'].length > 0 ? `
${french ? (data['relations']['friends'].length > 1 ? 'Amies ' : 'Amie ') : `Friend${data['relations']['friends'].length > 1 ? 's' : ''}`}: ${data['relations']['sisters'].length > 1 ? '
' : ''}
${data['relations']['friends'].map(relation => `
`).join(``)}
${data['relations']['friends'].length === 0 ? '-' : ''}
` : ``}
` : '
'}
`;
}