Skip to content

Commit

Permalink
feat: refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Oct 22, 2023
1 parent ecc59e1 commit 8339893
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ body::-webkit-scrollbar {
left: 0;
width: 100%;
height: 100%;
background-color: #212529;
background-color: #111111;
z-index: 1056 !important;
}

Expand Down
31 changes: 17 additions & 14 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const util = (() => {
origin: { y: 0.8 },
zIndex: 1057
});
await session.login();
await session.check();
await animation();
};

Expand Down Expand Up @@ -414,22 +414,24 @@ const session = (() => {
});
};

return {
login: async () => {
const token = localStorage.getItem('token');
const check = async () => {
const token = localStorage.getItem('token');

if (token) {
const jwt = JSON.parse(atob(token.split('.')[1]));
if (token) {
const jwt = JSON.parse(atob(token.split('.')[1]));

if (jwt.exp < ((new Date()).getTime() / 1000)) {
await login();
} else {
await comment.ucapan();
}
} else {
if (jwt.exp < ((new Date()).getTime() / 1000)) {
await login();
} else {
await comment.ucapan();
}
},
} else {
await login();
}
};

return {
check: check,
};
})(); // OK

Expand Down Expand Up @@ -516,6 +518,7 @@ const comment = (() => {
const resetForm = () => {
kirim.style.display = 'block';
hadiran.style.display = 'block';

batal.style.display = 'none';
balas.style.display = 'none';
sunting.style.display = 'none';
Expand All @@ -534,7 +537,7 @@ const comment = (() => {
// OK
const send = async () => {
let nama = formnama.value;
let hadir = hadiran.value;
let hadir = parseInt(hadiran.value);
let komentar = formpesan.value;
let token = localStorage.getItem('token') ?? '';

Expand Down

0 comments on commit 8339893

Please sign in to comment.