aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/js/app.js
diff options
context:
space:
mode:
authorJohannes Zellner <johannes@cloudron.io>2017-04-09 23:27:50 +0200
committerJohannes Zellner <johannes@cloudron.io>2017-04-09 23:27:50 +0200
commit8a3d0eee58f915ed0319cf219e03cfba98426cf3 (patch)
tree7048989c4ead067dc6955c8899633f18d40dad15 /frontend/js/app.js
parentc03cdd301e41e4400f2dd0006f97405782c4726a (diff)
downloadSurfer-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.js7
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
89function getExtension(entry) {
90 if (entry.isFile) return entry.filePath.slice(entry.filePath.lastIndexOf('.') + 1);
91 return '';
92}
93
88function refresh() { 94function 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;