mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
feat: show file's upload date in album pages
This commit is contained in:
parent
ff397fbf28
commit
db03240d06
@ -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')
|
||||
|
||||
|
@ -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()
|
||||
|
@ -129,7 +129,8 @@
|
||||
</a>
|
||||
<div class="details">
|
||||
<p class="name">{{ file.name }}</p>
|
||||
<p class="file-size">{{ file.size }} B</p>
|
||||
<p class="file-size" data-value="{{ file.size }}">{{ file.size }} B</p>
|
||||
<p class="file-date" data-value="{{ file.timestamp }}"></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user