diff --git a/routes/album.js b/routes/album.js index be47dbe..7534ebc 100644 --- a/routes/album.js +++ b/routes/album.js @@ -47,7 +47,7 @@ routes.get('/a/:identifier', async (req, res) => { } const files = await utils.db.table('files') - .select('name', 'size') + .select('name', 'size', 'timestamp') .where('albumid', album.id) .orderBy('id', 'desc') diff --git a/src/js/album.js b/src/js/album.js index 8f5b800..bec3870 100644 --- a/src/js/album.js +++ b/src/js/album.js @@ -8,9 +8,21 @@ const page = { } window.addEventListener('DOMContentLoaded', () => { - const elements = document.querySelectorAll('.file-size') - for (let i = 0; i < elements.length; i++) { - elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\s*B$/i, ''))) + const files = document.querySelectorAll('.image-container') + + // Prettify individual file's data rows + for (let i = 0; i < files.length; i++) { + const sizeElem = files[i].querySelector('.details .file-size') + if (sizeElem) { + const str = sizeElem.dataset.value || sizeElem.innerHTML.replace(/\s*B$/i, '') + sizeElem.innerHTML = page.getPrettyBytes(parseInt(str)) + } + + const dateElem = files[i].querySelector('.details .file-date') + if (dateElem) { + const str = dateElem.dataset.value + dateElem.innerHTML = page.getPrettyDate(new Date(parseInt(str) * 1000)) + } } page.lazyLoad = new LazyLoad() diff --git a/views/album.njk b/views/album.njk index ceaff23..62ba111 100644 --- a/views/album.njk +++ b/views/album.njk @@ -129,7 +129,8 @@
{{ file.name }}
-{{ file.size }} B
+{{ file.size }} B
+