From 8a3d0eee58f915ed0319cf219e03cfba98426cf3 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Sun, 9 Apr 2017 23:27:50 +0200 Subject: Make folder listing sortable --- frontend/js/app.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'frontend/js/app.js') diff --git a/frontend/js/app.js b/frontend/js/app.js index 0875f14..b8bd1d9 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -85,6 +85,12 @@ function getPreviewUrl(entry, basePath) { return path + 'unknown.png'; } +// simple extension detection, does not work with double extension like .tar.gz +function getExtension(entry) { + if (entry.isFile) return entry.filePath.slice(entry.filePath.lastIndexOf('.') + 1); + return ''; +} + function refresh() { loadDirectory(app.path); } @@ -103,6 +109,7 @@ function loadDirectory(filePath) { result.body.entries.sort(function (a, b) { return a.isDirectory && b.isFile ? -1 : 1; }); app.entries = result.body.entries.map(function (entry) { entry.previewUrl = getPreviewUrl(entry, filePath); + entry.extension = getExtension(entry); return entry; }); app.path = filePath; -- cgit v1.2.3