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>
</body>
<script>
const text = document.getElementById("text-splashscreen");
if (window.navigator.onLine === false) {
text.innerHTML = "You appear to be offline. Please connect to the internet and try again.";
} else {
text.innerHTML = "Starting ArmCord...";
if (window.armcord.version === "DEV") {
console.log("Running a development build of ArmCord. Skipping updater.");
async function loadLang() {
const text = document.getElementById("text-splashscreen");
if (window.navigator.onLine === false) {
text.innerHTML = await armcord.getLang("loading_screen_offline");
} else {
fetch("https://armcord.xyz/latest.json")
.then((response) => response.json())
.then((data) => {
if (data.version !== window.armcord.version) {
var elem = document.createElement("img");
elem.classList.add("logo");
elem.src = "https://armcord.smartfridge.space/update.webp";
document.body.prepend(elem);
document.getElementById("splashscreen-armcord").remove();
text.innerHTML =
"A new version of ArmCord is available. Please update to the latest version.";
} 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");
text.innerHTML = await armcord.getLang("loading_screen_start");
if (window.armcord.version === "DEV") {
console.log("Running a development build of ArmCord. Skipping updater.");
} else {
const response = await fetch("https://armcord.xyz/latest.json");
const data = await response.json();
if (data.version !== window.armcord.version) {
var elem = document.createElement("img");
elem.classList.add("logo");
elem.src = "https://armcord.smartfridge.space/update.webp";
document.body.prepend(elem);
document.getElementById("splashscreen-armcord").remove();
text.innerHTML = await armcord.getLang("loading_screen_update");
} else {
console.log("ArmCord is up to date.");
}
}
}, 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>
</html>