Add Sort folders first in sort mode Name & Size
This commit is contained in:
parent
37b78f6c61
commit
985324970e
1 changed files with 25 additions and 2 deletions
27
js/main.js
27
js/main.js
|
@ -97,7 +97,10 @@ $(document).ready(function () {
|
|||
var collator = new Intl.Collator([], {numeric: true});
|
||||
filesData.sort(function (fileA, fileB) {
|
||||
return collator.compare(fileA.name.toLowerCase(), fileB.name.toLowerCase());
|
||||
//return fileA.name.toLowerCase().localeCompare(fileB.name.toLowerCase());
|
||||
});
|
||||
|
||||
filesData.sort(function (fileA, fileB) {
|
||||
return collator.compare(fileA.type.toLowerCase(), fileB.type.toLowerCase());
|
||||
});
|
||||
|
||||
} else if (sortBy === "size") {
|
||||
|
@ -112,6 +115,16 @@ $(document).ready(function () {
|
|||
|
||||
fileListElement.empty();
|
||||
|
||||
var directories = [];
|
||||
var files = [];
|
||||
filesData.forEach(function (fileData) {
|
||||
if (fileData.type === "folder") {
|
||||
directories.push(fileData);
|
||||
} else {
|
||||
files.push(fileData);
|
||||
}
|
||||
});
|
||||
|
||||
var parentDir = getParentDir(path);
|
||||
|
||||
if (parentDir) {
|
||||
|
@ -122,7 +135,17 @@ $(document).ready(function () {
|
|||
));
|
||||
}
|
||||
|
||||
filesData.forEach(function (fileData) {
|
||||
directories.forEach(function (fileData) {
|
||||
fileListElement.append(renderFileElement(
|
||||
path,
|
||||
fileData.name,
|
||||
fileData.type,
|
||||
fileData.size,
|
||||
fileData.mtime
|
||||
));
|
||||
});
|
||||
|
||||
files.forEach(function (fileData) {
|
||||
fileListElement.append(renderFileElement(
|
||||
path,
|
||||
fileData.name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue