@@ -246,7 +247,14 @@
//
// Create dynamic TR for files
//
+ let totalSize = 0
+
function prepareFileTR(data) {
+ totalSize = totalSize + data.size
+ // Calculate the total size
+ const totalSizeElement = document.getElementById('totalsize');
+ totalSizeElement.innerText = humanReadableSize(totalSize);
+
const tr = document.createElement('tr')
tr.innerHTML = `
|
diff --git a/src/http/html/index.js b/src/http/html/index.js
index 19991a3..d1a7aad 100644
--- a/src/http/html/index.js
+++ b/src/http/html/index.js
@@ -33,12 +33,15 @@ function makeid(length) {
}
function sort(arr, key) {
- return arr.sort((a, b) => {
- if (a[key] < b[key]) return -1
- if (a[key] > b[key]) return 1
-
- return 0
- })
+ if (key === "createdAt") {
+ return arr.sort((b, a) => new Date(a[key]) - new Date(b[key]));
+ } else {
+ return arr.sort((a, b) => {
+ if (a[key] < b[key]) return -1
+ if (a[key] > b[key]) return 1
+ return 0
+ })
+ }
}
function download(url) {
const a = document.createElement('a')
@@ -136,7 +139,7 @@ async function refreshTable() {
for (const directory of sort(body.child.directories, 'name')) {
tbody.appendChild(prepareFolderTR(directory))
}
- for (const file of sort(body.child.files, 'name')) {
+ for (const file of sort(body.child.files, 'name')) { //replace "name" by "createdAt" to filter by date
tbody.appendChild(prepareFileTR(file))
}
}
|