From 9e1d65388b79d733a3ef3fa8bb7653895f3dbd1a Mon Sep 17 00:00:00 2001 From: dewanakl Date: Mon, 23 Dec 2024 21:24:32 +0700 Subject: [PATCH] refactor: update modal function --- index.html | 18 +++++++++--------- js/admin.js | 6 +++--- js/app.js | 2 -- js/guest.js | 12 ++++++++++++ js/theme.js | 2 +- js/util.js | 12 ------------ 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/index.html b/index.html index 80d1ee9..6c39605 100644 --- a/index.html +++ b/index.html @@ -121,7 +121,7 @@

Undangan Pernikahan

- bg + bg

Wahyu & Riski

Rabu, 15 Maret 2023

@@ -163,7 +163,7 @@

Assalamualaikum Wara
- cowo + cowo

Nama Wahyu Siapa

Putra ke-1

Bapak ... dan Ibu ...

@@ -190,7 +190,7 @@

&

- cewe + cewe

Nama Riski Siapa

Putri ke-2

Bapak ... dan Ibu ...

@@ -319,13 +319,13 @@

Galeri @@ -349,13 +349,13 @@

Galeri diff --git a/js/admin.js b/js/admin.js index fe12a21..c912d90 100644 --- a/js/admin.js +++ b/js/admin.js @@ -251,9 +251,9 @@ export const admin = (() => { comment.init(); try { - const jwt = session.decode(); - if (!jwt || (jwt.exp ?? 0) < (Date.now() / 1000)) { - throw new Error('invalid token'); + const exp = session.decode()?.exp; + if (!exp || exp < (Date.now() / 1000)) { + throw new Error('Invalid token'); } getUserDetail(); diff --git a/js/app.js b/js/app.js index 8b66d2e..636db42 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,6 @@ import { theme } from './theme.js'; import { audio } from './audio.js'; import { offline } from './offline.js'; import { comment } from './comment.js'; -import { progress } from './progress.js'; import { pagination } from './pagination.js'; document.addEventListener('DOMContentLoaded', () => { @@ -13,7 +12,6 @@ document.addEventListener('DOMContentLoaded', () => { audio.init(); guest.init(); offline.init(); - progress.init(); pagination.init(); window.AOS.init(); diff --git a/js/guest.js b/js/guest.js index fd31456..148a722 100644 --- a/js/guest.js +++ b/js/guest.js @@ -145,6 +145,15 @@ export const guest = (() => { util.timeOut(animation, 1500); }; + /** + * @param {HTMLImageElement} img + * @returns {void} + */ + const modal = (img) => { + document.getElementById('show-modal-image').src = img.src; + bootstrap.Modal.getOrCreateInstance('#modal-image').show(); + }; + /** * @returns {void} */ @@ -177,12 +186,14 @@ export const guest = (() => { if (document.body.getAttribute('data-key')?.length === 0) { document.getElementById('comment')?.remove(); document.querySelector('a.nav-link[href="#comment"]')?.closest('li.nav-item')?.remove(); + progress.init(); return; } progress.add(); progress.add(); comment.init(); + progress.init(); session.guest() .then((res) => { @@ -203,6 +214,7 @@ export const guest = (() => { init, open, name, + modal, closeInformation, }; })(); \ No newline at end of file diff --git a/js/theme.js b/js/theme.js index 28fa8a5..928b25f 100644 --- a/js/theme.js +++ b/js/theme.js @@ -217,9 +217,9 @@ export const theme = (() => { }; return { - change, init, spyTop, + change, isDarkMode, showButtonChangeTheme }; diff --git a/js/util.js b/js/util.js index 5c03000..9e6a5e6 100644 --- a/js/util.js +++ b/js/util.js @@ -1,5 +1,3 @@ -import { bootstrap } from './bootstrap.js'; - export const util = (() => { /** @@ -68,15 +66,6 @@ export const util = (() => { */ const animate = (svg, timeout, classes) => timeOut(() => svg.classList.add(classes), timeout); - /** - * @param {HTMLImageElement} img - * @returns {void} - */ - const modal = (img) => { - document.getElementById('show-modal-image').src = img.src; - bootstrap.Modal.getOrCreateInstance('#modal-image').show(); - }; - const copy = async (button, message = null, timeout = 1500) => { const copy = button.getAttribute('data-copy'); @@ -127,7 +116,6 @@ export const util = (() => { return { open, copy, - modal, timeOut, animate, escapeHtml,