@@ -8,10 +8,11 @@ var editable = undefined;
8
8
async function refresh_list ( ) {
9
9
10
10
function compareValues ( a , b ) {
11
- if ( a . value === b . value ) {
11
+ if ( a . directory == b . directory && a . name . toLowerCase ( ) === b . name . toLowerCase ( ) ) {
12
12
return 0 ;
13
13
} else {
14
- return a . value < b . value ? - 1 : 1 ;
14
+ return a . directory . toString ( ) . substring ( 3 , 4 ) + a . name . toLowerCase ( ) <
15
+ b . directory . toString ( ) . substring ( 3 , 4 ) + b . name . toLowerCase ( ) ? - 1 : 1 ;
15
16
}
16
17
}
17
18
@@ -52,10 +53,6 @@ async function refresh_list() {
52
53
}
53
54
}
54
55
55
- var dirCells = [ ] ;
56
- var dataCells = [ ] ;
57
- var index = 0 ;
58
-
59
56
if ( window . location . path != "/fs/" ) {
60
57
var clone = template . content . cloneNode ( true ) ;
61
58
var td = clone . querySelectorAll ( "td" ) ;
@@ -66,16 +63,11 @@ async function refresh_list() {
66
63
path . textContent = ".." ;
67
64
// Remove the delete button
68
65
td [ 4 ] . replaceChildren ( ) ;
69
-
70
- var sortdata = { } ;
71
- sortdata . value = ".." ;
72
- sortdata . index = index ;
73
- dirCells . push ( sortdata ) ;
74
- index += 1 ;
75
-
76
66
new_children . push ( clone ) ;
77
67
}
78
68
69
+ data . sort ( compareValues ) ;
70
+
79
71
for ( const f of data ) {
80
72
// Clone the new row and insert it into the table
81
73
var clone = template . content . cloneNode ( true ) ;
@@ -118,39 +110,10 @@ async function refresh_list() {
118
110
edit_link . href = edit_url
119
111
}
120
112
121
- var dataCell = td [ 2 ] ;
122
-
123
- var sortdata = { } ;
124
- sortdata . value = dataCell . textContent . toLowerCase ( ) . trim ( ) ;
125
- sortdata . index = index ;
126
- if ( ! f . directory ) {
127
- dataCells . push ( sortdata ) ;
128
- index += 1 ;
129
- } else {
130
- dirCells . push ( sortdata ) ;
131
- index += 1 ;
132
- }
133
-
134
113
new_children . push ( clone ) ;
135
114
}
136
-
137
- dirCells . sort ( compareValues ) ;
138
- dataCells . sort ( compareValues ) ;
139
-
140
115
var tbody = document . querySelector ( "tbody" ) ;
141
-
142
- // remove rows
143
- while ( tbody . firstChild ) {
144
- tbody . removeChild ( tbody . lastChild ) ;
145
- }
146
-
147
- // add sorted rows
148
- for ( var i = 0 ; i < dirCells . length ; i += 1 ) {
149
- tbody . appendChild ( new_children [ dirCells [ i ] . index ] ) ;
150
- }
151
- for ( var i = 0 ; i < dataCells . length ; i += 1 ) {
152
- tbody . appendChild ( new_children [ dataCells [ i ] . index ] ) ;
153
- }
116
+ tbody . replaceChildren ( ...new_children ) ;
154
117
}
155
118
156
119
async function find_devices ( ) {
0 commit comments