Fix splash for subtitles

This commit is contained in:
Maciej Jur 2023-04-08 16:42:03 +02:00
parent df99ead67a
commit cd515ec8d9
2 changed files with 17 additions and 4 deletions

View file

@ -1,4 +1,5 @@
const a = [ /** Subtitles dusplayed under site title in navbar. */
const subtitles = [
"Playtime's over, playtime's now", "Playtime's over, playtime's now",
"永遠のオデッセイ", "永遠のオデッセイ",
"0% code coverage", "0% code coverage",
@ -40,6 +41,12 @@ const a = [
"a2Ftb3NoaS5vcmc=", "a2Ftb3NoaS5vcmc=",
":: (Thought a) => a -> String", ":: (Thought a) => a -> String",
]; ];
a.push(`${Math.round(1 / a.length * 10000)/100}% chance for this message`);
const target = document.getElementById("p-nav-splash"); const chance = Math.round(1 / (subtitles.length + 1) * 10000) / 100;
target && (target.innerText = a[Math.floor(Math.random() * a.length)]); subtitles.push(`${chance}% chance for this message`);
export function bindSubtitle() {
const target = document.getElementById("p-nav-splash");
const choice = subtitles[Math.floor(Math.random() * subtitles.length)];
target && (target.innerText = choice);
}

View file

@ -68,3 +68,9 @@ const menu: MenuItem[] = [
))} ))}
</menu> </menu>
</nav> </nav>
<script>
import { bindSubtitle } from "../../assets/splash"
bindSubtitle();
</script>