You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
2.9 KiB

<video loop autoplay src="https://cdn.openasar.dev/discord_loading.webm"></video>
<div id="text">Starting...</div>
<div id="bar-container"><div id="bar-fill"></div></div>
<div id="debug"></div>
<style>
:root {
--background-primary: #282b30;
--background-secondary: rgba(255, 255, 255, 0.1);
--brand-experiment: #5865F2;
--header-primary: #fff;
--text-muted: #72767d;
--font-primary: 'Whitney', sans-serif;
}
@font-face {
font-family: Whitney;
font-weight: 400;
font-style: normal;
src: url(https://cdn.openasar.dev/whitney_400.woff) format("woff");
}
html, body {
-webkit-app-region: drag;
overflow: hidden;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background: var(--background-primary);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
* {
font-family: var(--font-primary);
box-sizing: border-box;
-webkit-user-select: none;
cursor: default;
}
video {
width: 200px;
height: 150px;
object-fit: cover;
}
#text {
text-align: center;
color: var(--header-primary);
font-weight: 400;
font-style: italic;
font-size: 16px;
text-transform: uppercase;
width: 100%;
}
#bar-container, #bar-fill {
width: 180px;
height: 8px;
border-radius: 4px;
visibility: hidden;
}
#bar-container {
background-color: var(--background-secondary);
position: relative;
margin-top: 12px;
}
#bar-fill {
background-color: var(--brand-experiment);
width: 0;
}
#debug {
position: absolute;
bottom: 6px;
right: 6px;
text-align: right;
font-size: 10px;
color: var(--text-muted);
white-space: pre;
}
</style>
<script>
const text = document.querySelector('#text');
const barContainer = document.querySelector('#bar-container');
const barFill = document.querySelector('#bar-fill');
DiscordSplash.signalReady();
DiscordSplash.onStateUpdate(({ status, current, total, progress, seconds }) => {
let statusText = status.replaceAll('-', ' ');
let showProgress = false;
switch (status) {
case 'downloading-updates': // X of Y states
case 'installing-updates':
statusText = statusText.slice(0, -1) + ` ${current} of ${total}`; // Remove "s" and concat
showProgress = true;
break;
case 'update-failure': // Custom for update failure, include retry and reorder text
statusText = `Update Failed - Retrying in ${seconds}`;
break;
case 'launching':
statusText = 'Starting...';
break;
}
text.textContent = statusText;
if (showProgress) {
barContainer.style.visibility = 'visible';
barFill.style.visibility = 'visible';
barFill.style.width = 100 * (progress / 100) + '%';
} else {
barContainer.style.visibility = '';
barFill.style.visibility = '';
}
});
</script>