diff options
Diffstat (limited to 'app/banner.js')
-rw-r--r-- | app/banner.js | 97 |
1 files changed, 70 insertions, 27 deletions
diff --git a/app/banner.js b/app/banner.js index 6daa2b7..8dd42a4 100644 --- a/app/banner.js +++ b/app/banner.js @@ -1,4 +1,5 @@ // noinspection JSUnresolvedVariable +window.bannerFrench = false; function timeAgo(time) { if (!isNaN(parseInt(time))) { @@ -6,6 +7,11 @@ function timeAgo(time) { } 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(); @@ -14,12 +20,22 @@ function timeAgo(time) { let tense; let period; - if (difference <= 10 && difference >= 0) { - return tense = "now"; - } else if (difference > 0) { - tense = "ago"; + if (bannerFrench) { + if (difference <= 10 && difference >= 0) { + return "à l'instant"; + } else if (difference > 0) { + tense = "il y a"; + } else { + tense = "dans"; + } } else { - tense = "later"; + if (difference <= 10 && difference >= 0) { + return "now"; + } else if (difference > 0) { + tense = "ago"; + } else { + tense = "later"; + } } let j; @@ -31,11 +47,19 @@ function timeAgo(time) { difference = Math.round(difference); period = periods[j] + (difference > 1 ? "s" : ''); - return `${difference} ${period} ${tense}`; + + if (bannerFrench) { + return `${tense} ${difference} ${period}`; + } else { + return `${difference} ${period} ${tense}`; + } } -async function refreshBanner(offline) { +async function refreshBanner(offline, french) { if (!offline) offline = false; + if (!french) french = false; + + window.bannerFrench = french; let data = window.currentMemberData; let index; @@ -84,12 +108,16 @@ async function refreshBanner(offline) { <div id="system-info" style="border:1px solid #${data['color']};background:rgba(255, 255, 255, .1);border-radius:10px;display:grid;grid-template-columns: 128px 1fr;"> <div style="margin:10px;width:100%;display:flex;align-items: center;justify-content: center;"> - <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']}" alt="" style="background-color:rgba(255, 255, 255, .125);width:128px;height:128px;border-radius:5px;"> + <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;"> - ${data['name']} + ${data['id'] === "unknown" ? ` + <span class="text-muted">Unknown member (${data['system']['name']} System)</span> + ` : data['id'] === "fusion" ? (data['name'] === "fusion" ? ` + <span class="text-muted">Multiple merged members</span> + ` : data['name']) : data['name']} </h3> <div style="margin-bottom:0.5rem;"> @@ -97,65 +125,80 @@ async function refreshBanner(offline) { ${data['badges'].length === 0 ? " " : ""} </div> - <div style="display:grid;grid-template-columns: repeat(${data['median'] ? 4 : 5}, 1fr);" id="member-card"> + <div style="display:grid;grid-template-columns: repeat(${data['median'] || data['id'] === "unknown" ? 4 : data['id'] === "fusion" ? 3 : 5}, 1fr);" id="member-card"> <span> - <b>Prefix${data['prefixes'].length > 1 ? 'es' : ''}: </b> + <b>${french ? `Préfixe${data['prefixes'].length > 1 ? 's' : ''} ` : `Prefix${data['prefixes'].length > 1 ? 'es' : ''}`}: </b> <code style="color: white;">${data['prefixes'].join('</code>, <code style="color: white;">')}</code> </span> <span> - <b>Pronouns: </b> - ${data['pronouns']} + <b>${french ? "Pronoms :" : "Pronouns:"} </b> + ${data['id'] === "fusion" ? "she/her" : data['pronouns']} </span> - ${!data['median'] ? ` + ${!data['median'] && data['id'] !== "unknown" ? ` <span> - <b>Last fronted: </b> + ${data["id"] === "fusion" ? ` + <b>Fronting since : </b> ${data['last_fronted'] ? ` ${data['last_fronted']['now'] ? ` - Right now<br> - (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> + ` : ` + <span class="text-muted">Not fronting</span><br> + `} + ` : `<span class="text-muted">Not fronting</span><br> `}` : ` + <b>${french ? "Front :" : "Last fronted:"} </b> + ${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> - (for ${data['last_fronted']['duration']['pretty']}) + (${french ? "pendant" : "for"} ${data['last_fronted']['duration']['pretty']}) `} - ` : "A long time ago<br> "} + ` : `${french ? "Il y a très longtemps" : "A long time ago"}<br> `}`} </span> ` : ''} + ${data['id'] !== "fusion" ? ` <span> - <span style="vertical-align: middle;position:relative;top:-5px;"><b>Species: </b></span> + ${data['id'] === "unknown" ? "<b>Species: </b> best to ask" : ` + <span style="vertical-align: middle;position:relative;top:-5px;"><b>${french ? (data['species'].length > 1 ? "Espèces : " : "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> + `).join("")}`} + </span>` : ''} + ${data['id'] !== "fusion" ? ` <span> - <b>System: </b> + <b>${french ? "Système : " : "System: "}</b> <a class="member-link" href="${data['system']['page']}"><img style="width:24px;border-radius:5px;" src="${offline ? data['system']['icon_offline'] : `/assets/uploads/${data['system']['icon']}`}"> ${data['system']['name']}</a> ${data['system']['subsystem'] ? ` - <br><b>Subsystem: </b><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> + <br><b>${french ? "Sous-système : " : "Subsystem: "} </b><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'] ? '<br>(temporary)' : ''} </span> + ` : ''} </div> + ${data['id'] !== "unknown" && data['id'] !== "fusion" ? ` <div style="display:grid;grid-template-columns: repeat(${data["little"] ? "3" : "2"}, 1fr);margin-top:5px;"> <span> - <b>Marefriend${data['relations']['sisters'].length > 1 ? 's' : ''}: </b>${data['relations']['marefriends'].length > 1 ? '<span class="list-separator-mobile"><br></span>' : ''} + <b>${french ? (data['relations']['marefriends'].length > 1 ? 'Partenaires ' : 'Partenaire ') : `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 class="member-link" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `/assets/uploads/${relation['icon']}`}" style="width:24px;"> ${relation['name']}</a>`).join(`<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>`)} ${data['relations']['marefriends'].length === 0 ? '-' : ''} </span> <span> - <b>Sister${data['relations']['sisters'].length > 1 ? 's' : ''}: </b>${data['relations']['sisters'].length > 1 ? '<span class="list-separator-mobile"><br></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 class="member-link" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `/assets/uploads/${relation['icon']}`}" style="width:24px;"> ${relation['name']}</a>`).join(`<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>`)} ${data['relations']['sisters'].length === 0 ? '-' : ''} </span> ${data['little'] ? ` <span> - <b>Caretaker${data['relations']['sisters'].length > 1 ? 's' : ''}: </b>${data['relations']['caretakers'].length > 1 ? '<span class="list-separator-mobile"><br></span>' : ''} + <b>${french ? (data['relations']['sisters'].length > 1 ? 'Caretakers ' : 'Caretaker ') : `Caretakers${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 class="member-link" href="${relation['link']}"><img src="${offline ? relation['icon_offline'] : `/assets/uploads/${relation['icon']}`}" style="width:24px;"> ${relation['name']}</a>`).join(`<span class="list-separator-desktop">, </span><span class="list-separator-mobile"><br></span>`)} ${data['relations']['caretakers'].length === 0 ? '-' : ''} </span> ` : ''} </div> + ` : '<div style="margin-top:5px;"> </div>'} </div> </div> |