improve directory size display

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@207 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-06-27 21:59:07 +00:00
parent 7025cf09f5
commit d068d93073
4 changed files with 10 additions and 4 deletions

View File

@ -1,7 +1,7 @@
Package: webif Package: webif
Priority: optional Priority: optional
Section: web Section: web
Version: 0.5.6 Version: 0.5.7
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hummypkg.org.uk Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=2.11-5),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.2),jim-oo,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.6),ssmtp Depends: mongoose(>=2.11-5),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.2),jim-oo,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.6),ssmtp

View File

@ -221,6 +221,7 @@ foreach part [split $dir /] {
append stub $name append stub $name
puts "<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $stub]>$name</a> puts "<a href=$env(REQUEST_URI)?dir=[cgi_quote_url $stub]>$name</a>
} }
puts "<span class=filesize id=dirsize></span>"
puts "</legend>" puts "</legend>"
# Parent directory # Parent directory

View File

@ -20,13 +20,18 @@ function epginfo_callback(data, status, xhr)
function insert_folder_size(folder, size) function insert_folder_size(folder, size)
{ {
folder = folder.replace(/ /g, ''); folder = folder.replace(/ /g, '');
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
//console.log("Folder: (%s) = (%s)", folder, size); //console.log("Folder: (%s) = (%s)", folder, size);
$('#' + folder).text(' (' + size + 'iB)'); if (folder == "")
$('#dirsize').text(' (' + size + 'iB)');
else
$('#' + folder).text(' (' + size + 'iB)');
} }
function folder_size_callback(data, status, xhr) function folder_size_callback(data, status, xhr)
{ {
//console.log("Status: %s", status); //console.log("Status: %s", status);
//console.dir(data);
$.each(data, insert_folder_size); $.each(data, insert_folder_size);
} }

View File

@ -8,7 +8,7 @@ puts ""
cgi_input cgi_input
#cgi_dump #cgi_dump
set _cgi(dir) "/media/My Video" #set _cgi(dir) "/media/My Video"
set dir [dict get $_cgi dir] set dir [dict get $_cgi dir]
@ -18,7 +18,7 @@ puts "{"
foreach line [split [exec /mod/bin/busybox/du -h "$dir/"] "\n"] { foreach line [split [exec /mod/bin/busybox/du -h "$dir/"] "\n"] {
set fields [split $line "\t"] set fields [split $line "\t"]
set size [lindex $fields 0] set size [lindex $fields 0]
set node [lindex [split [lindex $fields 1] '/'] end] set node [lindex [split [lindex $fields 1] /] end]
puts "\"$node\" : \"$size\"," puts "\"$node\" : \"$size\","
} }
puts "\"dummy\" : \"\"" puts "\"dummy\" : \"\""