Add translation loading to splash

This commit is contained in:
smartfrigde 2022-06-14 17:54:50 +02:00
parent c979328aee
commit a29cb2a6a5

View file

@ -17,52 +17,53 @@
</div> </div>
</body> </body>
<script> <script>
const text = document.getElementById("text-splashscreen"); async function loadLang() {
if (window.navigator.onLine === false) { const text = document.getElementById("text-splashscreen");
text.innerHTML = "You appear to be offline. Please connect to the internet and try again."; if (window.navigator.onLine === false) {
} else { text.innerHTML = await armcord.getLang("loading_screen_offline");
text.innerHTML = "Starting ArmCord...";
if (window.armcord.version === "DEV") {
console.log("Running a development build of ArmCord. Skipping updater.");
} else { } else {
fetch("https://armcord.xyz/latest.json") text.innerHTML = await armcord.getLang("loading_screen_start");
.then((response) => response.json()) if (window.armcord.version === "DEV") {
.then((data) => { console.log("Running a development build of ArmCord. Skipping updater.");
if (data.version !== window.armcord.version) { } else {
var elem = document.createElement("img"); const response = await fetch("https://armcord.xyz/latest.json");
elem.classList.add("logo"); const data = await response.json();
elem.src = "https://armcord.smartfridge.space/update.webp"; if (data.version !== window.armcord.version) {
document.body.prepend(elem); var elem = document.createElement("img");
document.getElementById("splashscreen-armcord").remove(); elem.classList.add("logo");
text.innerHTML = elem.src = "https://armcord.smartfridge.space/update.webp";
"A new version of ArmCord is available. Please update to the latest version."; document.body.prepend(elem);
} else { document.getElementById("splashscreen-armcord").remove();
console.log("ArmCord is up to date."); text.innerHTML = await armcord.getLang("loading_screen_update");
} } else {
}); console.log("ArmCord is up to date.");
} }
setTimeout(() => {
window.armcordinternal.splashEnd();
switch (window.armcord.channel) {
case "stable":
window.location.replace("https://discord.com/app");
break;
case "canary":
window.location.replace("https://canary.discord.com/app");
break;
case "ptb":
window.location.replace("https://ptb.discord.com/app");
break;
case "foss":
window.location.replace("https://dev.fosscord.com/app");
break;
case undefined:
window.location.replace("https://discord.com/app");
break;
default:
window.location.replace("https://discord.com/app");
} }
}, 5000); setTimeout(() => {
window.armcordinternal.splashEnd();
switch (window.armcord.channel) {
case "stable":
window.location.replace("https://discord.com/app");
break;
case "canary":
window.location.replace("https://canary.discord.com/app");
break;
case "ptb":
window.location.replace("https://ptb.discord.com/app");
break;
case "foss":
window.location.replace("https://dev.fosscord.com/app");
break;
case undefined:
window.location.replace("https://discord.com/app");
break;
default:
window.location.replace("https://discord.com/app");
}
}, 5000);
}
} }
loadLang();
</script> </script>
</html> </html>