if language is not english, the rules button should re-open the modal instead of opening rules.html

This commit is contained in:
Elijah R 2024-04-09 18:27:43 -04:00
parent 2377e4aceb
commit 9cd578e453
3 changed files with 11 additions and 2 deletions

View File

@ -186,7 +186,7 @@
<a href="https://computernewb.com/collab-vm/faq/" class="nav-link"><i class="fa-solid fa-circle-question"></i> <span id="faqBtnText"></span></a> <a href="https://computernewb.com/collab-vm/faq/" class="nav-link"><i class="fa-solid fa-circle-question"></i> <span id="faqBtnText"></span></a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="https://computernewb.com/collab-vm/rules" class="nav-link"><i class="fa-solid fa-clipboard-check"></i> <span id="rulesBtnText"></span></a> <a id="rulesBtn" href="https://computernewb.com/collab-vm/rules" class="nav-link"><i class="fa-solid fa-clipboard-check"></i> <span id="rulesBtnText"></span></a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="https://discord.gg/a4kqb4mGyX" class="nav-link"><i class="fa-brands fa-discord"></i> Discord</a> <a href="https://discord.gg/a4kqb4mGyX" class="nav-link"><i class="fa-brands fa-discord"></i> Discord</a>

View File

@ -142,6 +142,8 @@ export class I18n {
private lang: Language = fallbackLanguage; private lang: Language = fallbackLanguage;
private languageDropdown: HTMLSpanElement = document.getElementById('languageDropdown') as HTMLSpanElement; private languageDropdown: HTMLSpanElement = document.getElementById('languageDropdown') as HTMLSpanElement;
CurrentLanguage = () => this.langId;
// the ID of the language // the ID of the language
private langId: string = fallbackId; private langId: string = fallbackId;

View File

@ -23,6 +23,7 @@ const elements = {
vmview: document.getElementById('vmview') as HTMLDivElement, vmview: document.getElementById('vmview') as HTMLDivElement,
vmDisplay: document.getElementById('vmDisplay') as HTMLDivElement, vmDisplay: document.getElementById('vmDisplay') as HTMLDivElement,
homeBtn: document.getElementById('homeBtn') as HTMLAnchorElement, homeBtn: document.getElementById('homeBtn') as HTMLAnchorElement,
rulesBtn: document.getElementById('rulesBtn') as HTMLAnchorElement,
chatList: document.getElementById('chatList') as HTMLTableSectionElement, chatList: document.getElementById('chatList') as HTMLTableSectionElement,
chatListDiv: document.getElementById('chatListDiv') as HTMLDivElement, chatListDiv: document.getElementById('chatListDiv') as HTMLDivElement,
userlist: document.getElementById('userlist') as HTMLTableSectionElement, userlist: document.getElementById('userlist') as HTMLTableSectionElement,
@ -1268,10 +1269,10 @@ document.addEventListener('DOMContentLoaded', async () => {
await loadList(); await loadList();
// Welcome modal // Welcome modal
let welcomeModal = new bootstrap.Modal(document.getElementById('welcomeModal') as HTMLDivElement);
let noWelcomeModal = window.localStorage.getItem('no-welcome-modal'); let noWelcomeModal = window.localStorage.getItem('no-welcome-modal');
if (noWelcomeModal !== '1') { if (noWelcomeModal !== '1') {
let welcomeModalDismissBtn = document.getElementById('welcomeModalDismiss') as HTMLButtonElement; let welcomeModalDismissBtn = document.getElementById('welcomeModalDismiss') as HTMLButtonElement;
let welcomeModal = new bootstrap.Modal(document.getElementById('welcomeModal') as HTMLDivElement);
welcomeModalDismissBtn.addEventListener('click', () => { welcomeModalDismissBtn.addEventListener('click', () => {
window.localStorage.setItem('no-welcome-modal', '1'); window.localStorage.setItem('no-welcome-modal', '1');
}); });
@ -1281,4 +1282,10 @@ document.addEventListener('DOMContentLoaded', async () => {
welcomeModalDismissBtn.disabled = false; welcomeModalDismissBtn.disabled = false;
}, 5000); }, 5000);
} }
elements.rulesBtn.addEventListener('click', e => {
if (TheI18n.CurrentLanguage() !== "en-us") {
e.preventDefault();
welcomeModal.show();
}
});
}); });