diff --git a/webif/html/browse/index.jim b/webif/html/browse/index.jim index 762a1c7c..669831e7 100755 --- a/webif/html/browse/index.jim +++ b/webif/html/browse/index.jim @@ -319,10 +319,39 @@ proc s_time {a b} { return 0 } +proc s_size {a b} { + global dir + + set a "$dir/$a" + set b "$dir/$b" + + set ad [file isdirectory $a] + set bd [file isdirectory $b] + + if {$ad && !$bd} { return -1 } + if {$bd && !$ad} { return 1 } + if {$ad && $bd} { + if {$a < $b} { return -1 } + if {$a > $b} { return 1 } + return 0 + } + + if {[catch {file stat $a l}]} { return 0} + set as $l(size) + if {[catch {file stat $b l}]} { return 0} + set bs $l(size) + + if {$as < $bs} { return -1 } + if {$as > $bs} { return 1 } + return 0 +} + set files [readdir -nocomplain $dir] switch $order { 1 { set files [lsort -command s_time $files] } 2 { set files [lreverse [lsort -command s_time $files]] } + 3 { set files [lsort -command s_size $files] } + 4 { set files [lreverse [lsort -command s_size $files]] } default { set files [lsort -nocase $files] } } @@ -337,19 +366,23 @@ Directories: $dircount, Files: $filecount # Sort icons puts "
" -set sortlist {{0 sort_name name} {1 sort_date date} {2 sort_date reverse-date}} +set sortlist { + {0 sort_name name} + {1 sort_date date} {2 sort_date reverse-date} + {3 sort_size size} {4 sort_size reverse-size}} +puts " +Sort by: " foreach sl $sortlist { lassign $sl index img descr if {$index} { puts " | " } - set tag "Currently sorting" + set tag " (current)" if {$order != $index} { - puts " - " - set tag "Sort" + puts "" + set tag "" } - puts " $tag by $descr" + puts " $descr$tag" if {$order != $index} { puts "" } @@ -443,4 +476,3 @@ if {[llength $plugins(buttons)]} { puts "
" footer -