diff options
author | Minteck <contact@minteck.org> | 2023-01-28 20:31:04 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-01-28 20:31:04 +0100 |
commit | 089d94ff3a34ef022015bf28db0427497acc67ea (patch) | |
tree | 2b7db486ba3cd7ebdd728599bb5af99eafe9bde4 /assets/logo | |
parent | 9b2f05228357a34a3c0f2950782835dfeb35086e (diff) | |
download | pluralconnect-089d94ff3a34ef022015bf28db0427497acc67ea.tar.gz pluralconnect-089d94ff3a34ef022015bf28db0427497acc67ea.tar.bz2 pluralconnect-089d94ff3a34ef022015bf28db0427497acc67ea.zip |
Updated 7 files and renamed 2 files (automated)
Diffstat (limited to 'assets/logo')
-rw-r--r-- | assets/logo/banner.js | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/assets/logo/banner.js b/assets/logo/banner.js new file mode 100644 index 0000000..076e8ce --- /dev/null +++ b/assets/logo/banner.js @@ -0,0 +1,185 @@ +// 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 = ` + +<div id="system-info" style="background:#${data['color']}55;border-radius:10px;display:grid;grid-template-columns: 128px 1fr; margin-left:-20px;margin-right: -20px;margin-top: -20px; padding: 0 10px;"> + <div style="margin:10px;width:100%;display:flex;align-items: center;justify-content: center;" id="member-icon-outer"> + <img id="member-icon" src="${offline ? JSON.parse(await localforage.getItem("images")).profile[data['icon']['offline'].split(".")[0].split("-")[1]][data['icon']['offline'].split(".")[0].split("-")[2]] : (data['icon']['online'] ?? (data['id'] === "fusion" ? '/assets/logo/logo.png' : data['system']['icon']))}" alt="" style="background-color:rgba(255, 255, 255, .125);width:128px;height:128px;border-radius:5px;"> + </div> + + <div style="padding:10px 10px 10px 20px;text-align:center;"> + <h3 style="margin-bottom:0;"> + <img id="member-icon-mobile" src="${offline ? JSON.parse(await localforage.getItem("images")).profile[data['icon']['offline'].split(".")[0].split("-")[1]][data['icon']['offline'].split(".")[0].split("-")[2]] : (data['icon']['online'] ?? (data['id'] === "fusion" ? '/assets/logo/logo.png' : data['system']['icon']))}" alt="" style="background-color:rgba(255, 255, 255, .125);width:36px;height:36px;border-radius:999px;display:none;margin-right:5px;"> + <span style="vertical-align: middle;"> + ${data['id'] === "unknown" ? ` + <span class="text-muted">${french ? "Membre inconnu" : "Unknown member"} (${data['system']['name']} System)</span> + ` : data['id'] === "fusion" ? (data['name'] === "fusion" ? ` + <span class="text-muted">${french ? "Plusieurs membres fusionnés" : "Multiple merged members"}</span> + ` : data['name']) : data['name']} + </span> + </h3> + + <div style="margin-bottom:0.5rem;"> + ${data['badges'].map(i => i.html).join(" ")} + ${data['badges'].length === 0 ? " " : ""} + </div> + + <div style="display:grid;grid-template-columns: repeat(${data['median'] || data['id'] === "unknown" ? (french ? 3 : 4) : data['id'] === "fusion" ? (french ? 2 : 3) : (french ? 4 : 5)}, 1fr);" id="member-card"> + <span> + <b>${french ? `Préfixe${data['prefixes'].length > 1 ? 's' : ''} ` : `Prefix${data['prefixes'].length > 1 ? 'es' : ''}`}: </b><span class="member-small-separator"><br></span> + ${data['prefixes'].length > 0 && data['prefixes'][0] !== null ? `<code style="color: white;">${data['prefixes'].join('</code>, <code style="color: white;">')}</code>` : `-`} + </span> + ${french ? "" : `<span> + <b>${french ? "Pronoms :" : "Pronouns:"} </b><span class="member-small-separator"><br></span> + ${data['id'] === "fusion" ? "she/her" : data['pronouns']} + </span>`} + ${!data['median'] && data['id'] !== "unknown" ? ` + <span> + ${data["id"] === "fusion" ? ` + <b>${french ? "Fronte depuis " : "Fronting since"}: </b><span class="member-small-separator"><br></span> + ${data['last_fronted'] ? ` + ${data['last_fronted']['now'] ? ` + <span class="relative-time" data-relative-timestamp="${data['last_fronted']['timestamp']}">${data['last_fronted']['relative']}</span><br> + ` : ` + <span class="text-muted">${french ? "Pas au front" : "Not fronting"}</span><br> + `} + ` : `<span class="text-muted">${french ? "Pas au front" : "Not fronting"}</span><br> `}` : ` + <b>${french ? "Front :" : "Last fronted:"} </b><span class="member-small-separator"><br></span> + ${data['last_fronted'] ? ` + ${data['last_fronted']['now'] ? ` + ${french ? "En ce moment" : "Right now"}<br> + (${french ? "commencé" : "started"} <span class="relative-time" data-relative-timestamp="${data['last_fronted']['timestamp']}">${data['last_fronted']['relative']}</span>) + ` : ` + <span class="relative-time" data-relative-timestamp="${data['last_fronted']['timestamp']}">${data['last_fronted']['relative']}</span><br> + (${french ? "pendant" : "for"} ${data['last_fronted']['duration']['pretty']}) + `} + ` : `${french ? "Jamais" : "Never"}<br> `}`} + </span> + ` : ''} + ${data['id'] !== "fusion" ? ` + <span> + ${data['id'] === "unknown" ? (french ? "<b>Espèce : </b> préférez demander" : "<b>Species: </b> best to ask") : ` + <span class="member-small-only"><b>${french ? "Espèce :" : "Species:"} </b></span> + ${data['species'].map(species => ` + <img data-bs-toggle="tooltip" title="${species['name']}" style="width:32px;vertical-align: middle;position:relative;top:-5px;" src="${offline ? species['icon_offline'] : `/assets/species/${species['icon']}`}" alt="${species['name']}"> + `).join("")}`} + </span>` : ''} + ${data['id'] !== "fusion" ? ` + <span> + <span class="member-small-only"><b>${french ? "Position :" : "Location:"} </b></span> + ${data['system']['page'] ? `<a class="member-link" href="${data['system']['page']}"><img style="width:24px;" src="${offline ? data['system']['icon_offline'] : `/assets/uploads/${data['system']['icon']}`}"> ${data['system']['name']}</a>` : `<img style="width:24px;" src="${offline ? data['system']['icon_offline'] : `/assets/uploads/${data['system']['icon']}`}"> ${data['system']['name']}`} + ${data['system']['subsystem'] ? ` + <br><span class="member-small-only"><b>${french ? "Sous-système :" : "Subsystem:"} </b></span><a class="member-link" href="${data['system']['subsystem']['page']}"><img style="width:24px;border-radius:5px;" src="/assets/uploads/${data['system']['subsystem']['icon']}"> ${data['system']['subsystem']['name']}</a> + ` : data['system']['temporary'] ? (french ? '<br>(temporaire)' : '<br>(temporary)') : ''} + </span> + ` : ''} + </div> + ${data['id'] !== "unknown" && data['id'] !== "fusion" ? ` + <div style="display:grid;grid-template-columns: repeat(${active}, 1fr);margin-top:5px;" id="member-relations"> + ${data['relations']['sexfriends'] && data['relations']['sexfriends'].length > 0 ? `<span> + <b>${french ? (data['relations']['sexfriends'].length > 1 ? 'Rel. sexuelles ' : 'Rel. sexuelle ') : `Sexfriend${data['relations']['sexfriends'].length > 1 ? 's' : ''}`}: </b>${data['relations']['sexfriends'].length > 1 ? '<span class="list-separator-mobile"><br></span>' : ''} + ${data['relations']['sexfriends'].map(relation => ` + <a title="${relation['name']}" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `${relation['icon']}`}" style="width:24px;"></a>`).join(``)} + ${data['relations']['sexfriends'].length === 0 ? '-' : ''} + </span>` : ``} + ${data['relations']['marefriends'] && data['relations']['marefriends'].length > 0 ? `<span> + <b>${french ? (data['relations']['marefriends'].length > 1 ? 'Copines ' : 'Copine ') : `Marefriend${data['relations']['marefriends'].length > 1 ? 's' : ''}`}: </b>${data['relations']['marefriends'].length > 1 ? '<span class="list-separator-mobile"><br></span>' : ''} + ${data['relations']['marefriends'].map(relation => ` + <a title="${relation['name']}" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `${relation['icon']}`}" style="width:24px;"></a>`).join(``)} + ${data['relations']['marefriends'].length === 0 ? '-' : ''} + </span>` : ``} + ${data['relations']['sisters'] && data['relations']['sisters'].length > 0 ? `<span> + <b>${french ? (data['relations']['sisters'].length > 1 ? 'Sœurs ' : 'Sœur ') : `Sister${data['relations']['sisters'].length > 1 ? 's' : ''}`}: </b>${data['relations']['sisters'].length > 1 ? '<span class="list-separator-mobile"><br></span>' : ''} + ${data['relations']['sisters'].map(relation => ` + <a title="${relation['name']}" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `${relation['icon']}`}" style="width:24px;"></a>`).join(``)} + ${data['relations']['sisters'].length === 0 ? '-' : ''} + </span>` : ``} + ${data['relations']['caretakers'] && data['relations']['caretakers'].length > 0 ? ` + <span> + <b>${french ? (data['relations']['caretakers'].length > 1 ? 'Gardiens ' : 'Gardien ') : `Caretaker${data['relations']['caretakers'].length > 1 ? 's' : ''}`}: </b>${data['relations']['caretakers'].length > 1 ? '<span class="list-separator-mobile"><br></span>' : ''} + ${data['relations']['caretakers'].map(relation => ` + <a title="${relation['name']}" data-bs-toggle="tooltip" class="member-link tooltip-nohelp" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `${relation['icon']}`}" style="width:24px;"></a>`).join(``)} + ${data['relations']['caretakers'].length === 0 ? '-' : ''} + </span> + ` : ''} + </div> + ` : '<div style="margin-top:5px;"> </div>'} + </div> +</div> + +`; +}
\ No newline at end of file |