diff options
author | Johannes Zellner <johannes@cloudron.io> | 2017-04-09 23:27:50 +0200 |
---|---|---|
committer | Johannes Zellner <johannes@cloudron.io> | 2017-04-09 23:27:50 +0200 |
commit | 8a3d0eee58f915ed0319cf219e03cfba98426cf3 (patch) | |
tree | 7048989c4ead067dc6955c8899633f18d40dad15 /frontend/js/app.js | |
parent | c03cdd301e41e4400f2dd0006f97405782c4726a (diff) | |
download | Surfer-8a3d0eee58f915ed0319cf219e03cfba98426cf3.tar.gz Surfer-8a3d0eee58f915ed0319cf219e03cfba98426cf3.tar.zst Surfer-8a3d0eee58f915ed0319cf219e03cfba98426cf3.zip |
Make folder listing sortable
Diffstat (limited to 'frontend/js/app.js')
-rw-r--r-- | frontend/js/app.js | 7 |
1 files changed, 7 insertions, 0 deletions
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) { | |||
85 | return path + 'unknown.png'; | 85 | return path + 'unknown.png'; |
86 | } | 86 | } |
87 | 87 | ||
88 | // simple extension detection, does not work with double extension like .tar.gz | ||
89 | function getExtension(entry) { | ||
90 | if (entry.isFile) return entry.filePath.slice(entry.filePath.lastIndexOf('.') + 1); | ||
91 | return ''; | ||
92 | } | ||
93 | |||
88 | function refresh() { | 94 | function refresh() { |
89 | loadDirectory(app.path); | 95 | loadDirectory(app.path); |
90 | } | 96 | } |
@@ -103,6 +109,7 @@ function loadDirectory(filePath) { | |||
103 | result.body.entries.sort(function (a, b) { return a.isDirectory && b.isFile ? -1 : 1; }); | 109 | result.body.entries.sort(function (a, b) { return a.isDirectory && b.isFile ? -1 : 1; }); |
104 | app.entries = result.body.entries.map(function (entry) { | 110 | app.entries = result.body.entries.map(function (entry) { |
105 | entry.previewUrl = getPreviewUrl(entry, filePath); | 111 | entry.previewUrl = getPreviewUrl(entry, filePath); |
112 | entry.extension = getExtension(entry); | ||
106 | return entry; | 113 | return entry; |
107 | }); | 114 | }); |
108 | app.path = filePath; | 115 | app.path = filePath; |