X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=frontend%2Fjs%2Fapp.js;h=b8bd1d985f2b6751be3de20989fe2f82f93dd030;hb=8a3d0eee58f915ed0319cf219e03cfba98426cf3;hp=0875f1459e0d820299ab9cb075e91c1ee9256dbd;hpb=c03cdd301e41e4400f2dd0006f97405782c4726a;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git 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;