Skip to content

Commit

Permalink
refactor: guest init
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Jan 23, 2025
1 parent 0c7c755 commit 99a30cc
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions js/app/guest/guest.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,23 @@ export const guest = (() => {
});
};

/**
* @returns {void}
*/
const booting = () => {
animateSvg();
countDownDate();
normalizeArabicFont();

if (information.has('presence')) {
document.getElementById('form-presence').value = information.get('presence') ? '1' : '2';
}

if (information.get('info')) {
document.getElementById('information')?.remove();
}
};

/**
* @returns {object}
*/
Expand All @@ -163,16 +180,7 @@ export const guest = (() => {
session.init();
offline.init();
progress.init();

information = storage('information');
document.addEventListener('progressDone', () => {
document.body.scrollIntoView({ behavior: 'instant' });
normalizeArabicFont();
window.AOS.init();
countDownDate();
showGuestName();
animateSvg();
});

if (session.isAdmin()) {
storage('user').clear();
Expand All @@ -183,14 +191,14 @@ export const guest = (() => {
storage('tracker').clear();
}

if (information.has('presence')) {
document.getElementById('form-presence').value = information.get('presence') ? '1' : '2';
}
document.addEventListener('progressDone', () => {
document.body.scrollIntoView({ behavior: 'instant' });
window.AOS.init();
booting();

const info = document.getElementById('information');
if (info && information.get('info')) {
info.remove();
}
// then show guest name.
showGuestName();
});

const token = document.body.getAttribute('data-key');
if (!token || token.length === 0) {
Expand Down

0 comments on commit 99a30cc

Please sign in to comment.