From 81abd5a101a52f7ca9c803af879815dacae028b1 Mon Sep 17 00:00:00 2001 From: ulrich Date: Thu, 28 Jan 2021 12:24:56 +0000 Subject: [PATCH] Sortieren aufgeraeumt --- web/ui2/js/app.js | 132 +++++--------------------------------------- src/java/de/uhilger/filecms/data/FileRef.java | 9 ++ 2 files changed, 22 insertions(+), 119 deletions(-) diff --git a/src/java/de/uhilger/filecms/data/FileRef.java b/src/java/de/uhilger/filecms/data/FileRef.java index 22bbe3e..e2f1906 100644 --- a/src/java/de/uhilger/filecms/data/FileRef.java +++ b/src/java/de/uhilger/filecms/data/FileRef.java @@ -41,7 +41,7 @@ private Boolean isHidden; private Long lastModified; private Long length; - private String mimetype; + private String mimetype = "text"; /** * create a new instance of <code>FileRef</code>. Note that the created FileRef is @@ -63,6 +63,9 @@ this.isHidden = isHidden; this.lastModified = lastModified; this.length = length; + if(isDirectory()) { + this.mimetype = " "; + } } /** @@ -99,7 +102,9 @@ } public void setMimetype(String mimetype) { - this.mimetype = mimetype; + if(mimetype != null && mimetype.length() > 1) { + this.mimetype = mimetype; + } } /** diff --git a/web/ui2/js/app.js b/web/ui2/js/app.js index ee0e407..ebabf3a 100644 --- a/web/ui2/js/app.js +++ b/web/ui2/js/app.js @@ -794,145 +794,44 @@ suedDiv.style.height = '0'; }; - /* - function descending(a, b) - { - if (a < b) - { - return 1; - } - - if (a > b) - { - return -1; - } - - return 0; - } - */ - // FileRef Vergleicher - this.name_vergleicher_asc = function(a, b) { - if (a.fileName() > b.fileName()) - { - return 1; - } - - if (a.fileName() < b.fileName()) - { - return -1; - } - + this.fm_vergleichen_asc = function(av, bv) { + if (av > bv) { return 1; } + if (av < bv) { return -1; } return 0; + }; + + this.name_vergleicher_asc = function(a, b) { + return self.fm_vergleichen_asc(a.fileName().small(), b.fileName().small()); }; this.name_vergleicher_desc = function(a, b) { - //console.log('name_vergleicher_desc - a.fileName: ' + - // a.fileName() + ', b.fileName: ' + b.fileName()); - if (a.fileName() < b.fileName()) - { - return 1; - } - - if (a.fileName() > b.fileName()) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(b.fileName().small(), a.fileName().small()); }; - // groesse fileSize, art fr.mimetype, geaendert fileDate - this.type_vergleicher_asc = function(a, b) { - if (a.fr.mimetype > b.fr.mimetype) - { - return 1; - } - - if (a.fr.mimetype < b.fr.mimetype) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(a.fr.mimetype.small(), b.fr.mimetype.small()); }; this.type_vergleicher_desc = function(a, b) { - //console.log('name_vergleicher_desc - a.fileName: ' + - // a.fileName() + ', b.fileName: ' + b.fileName()); - if (a.fr.mimetype < b.fr.mimetype) - { - return 1; - } - - if (a.fr.mimetype > b.fr.mimetype) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(b.fr.mimetype.small(), a.fr.mimetype.small()); }; this.size_vergleicher_asc = function(a, b) { - if (a.fileSize() > b.fileSize()) - { - return 1; - } - - if (a.fileSize() < b.fileSize()) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(a.fileSize(), b.fileSize()); }; this.size_vergleicher_desc = function(a, b) { - //console.log('name_vergleicher_desc - a.fileName: ' + - // a.fileName() + ', b.fileName: ' + b.fileName()); - if (a.fileSize() < b.fileSize()) - { - return 1; - } - - if (a.fileSize() > b.fileSize()) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(b.fileSize(), a.fileSize()); }; this.date_vergleicher_asc = function(a, b) { - if (a.fileDate() > b.fileDate()) - { - return 1; - } - - if (a.fileDate() < b.fileDate()) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(a.fileDate(), b.fileDate()); }; this.date_vergleicher_desc = function(a, b) { - //console.log('name_vergleicher_desc - a.fileName: ' + - // a.fileName() + ', b.fileName: ' + b.fileName()); - if (a.fileDate() < b.fileDate()) - { - return 1; - } - - if (a.fileDate() > b.fileDate()) - { - return -1; - } - - return 0; + return self.fm_vergleichen_asc(b.fileDate(), a.fileDate()); }; this.fm_toggle_order = function () { @@ -1025,8 +924,7 @@ } } var fl = new FileList(files); - self.fm_render_list(fl); - + self.fm_render_list(fl); } else { // #dateien leeren var elem = document.querySelector("#dateien"); -- Gitblit v1.9.3